Edit Page

.where()

Specify a where clause for filtering a query.

.where(whereClause)

Usage

#
Arguments Type Details
1 whereClause Dictionary The where clause to use for matching records in the database.

Example

#

To find all the users named Finn whose email addresses start with 'f':

var users = await User.find()
.where({ name: 'Finn', 'emailAddress' : { startsWith : 'f' } });

return res.json(users);

Notes

#

The criteria provided in the .where() method takes precendence over the the criteria provided in .find().

The .find() method returns a chainable object if you don't supply a callback. This method can be chained to .find() to further filter your results.

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Reference

Reference