.exec()Execute a Waterline query instance.
.exec(function (err, result) {
})
As of Sails v1 and Node.js v8, you can take advantage of
awaitinstead of using this method.
| Argument | Type | Details | |
|---|---|---|---|
| 1 | callback | The Node-style callback that will be called when the query completes, successfully or otherwise. |
| Argument | Type | Details | |
|---|---|---|---|
| 1 | err | The Error that occurred, or undefined if there were no errors. |
|
| 2 | result | The result from the database, if any. Exact data type depends on the query. If an error occurred (i.e. err is truthy), then this result argument should be ignored. |
Zookeeper.find().exec((err, zookeepers)=>{
if (err) {
return res.serverError(err);
}
// would you look at all those zookeepers?
return res.json(zookeepers);
});
//
// (don't put code out here)
- If you don't run
.exec()or use promises, your query will not execute. For help using.exec()with model methods like.find(), read more about the chainable query object.
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.