Find records in your database that match the given criteria.
Something.find(criteria).exec(function (err, records) {
});
| Argument | Type | Details | |
|---|---|---|---|
| 1 | criteria | The Waterline criteria to use for matching records in the database. |
| Argument | Type | Details | |
|---|---|---|---|
| 1 | err | The error that occurred, or null if there were no errors. |
|
| 2 | records | The array of records from your database which match the given criteria. |
To find any users named Finn in the database:
User.find({name:'Finn'}).exec(function (err, usersNamedFinn){
if (err) {
return res.serverError(err);
}
sails.log('Wow, there are %d users named Finn. Check it out:', usersNamedFinn.length, usersNamedFinn);
return res.json(usersNamedFinn);
});