Reputation: 1293
When you construct a query using Fluent in Vapor, can the list of .filter (or .sort, etc.) be manipulated? For example, before executing the query, can I add, remove of change those components?
Upvotes: 1
Views: 264
Reputation: 5200
You can't (as far as I know) remove a filter, sort, etc. However, you can add. This is an example:
var query = User.sort(\.$surname).sort(\.$forename)
query = query.filter(\.$surname == "Smith")
I'm not quite sure what you mean by change, but if you use a variable in the filter, the value used is taken when the query is executed:
var requiredSurname = "Smith"
let query = User.filter(\.$surname == requiredSurname)
requiredSurname = "Jones"
// go on to execute the query and it will retrieve the Joneses.
Upvotes: 2