.then()Execute a Waterline query instance using promises.
.then(callback)
As of Sails v1 and Node.js v8, you can take advantage of
awaitinstead of using this method.
| Argument | Type | Details | |
|---|---|---|---|
| 1 | callback | A function that runs if the query successfully completes Takes the result of the query as its argument.  | 
| Argument | Type | Details | |
|---|---|---|---|
| 1 | result | The result from the database, if any. Exact data type depends on the query. | 
To look up the user with the specified email address:
User.findOne({
  email: req.param('email')
})
.then(function (user){
  if (!user) { return res.notFound(); }
  return res.json(user);
})
.catch(function (err) { return res.serverError(err); });
- Whenever possible, it is recommended that you use
 awaitinstead of calling this method.- This is an alternative to
 .exec(). When combined with.catch(), it provides the same functionality.- The
 .then()function returns a promise to allow for chaining.- For more information, see the bluebird
 .then()api docs.