Back to Sails

`.fetch()`

docs/reference/waterline/queries/fetch.md

12.12.20001.2 KB
Original Source

.fetch()

Tell Waterline (and the underlying database adapter) to send back records that were updated/destroyed/created when performing an .update(), .create(), .createEach() or .destroy() query. Otherwise, no data will be returned (or if you are using callbacks, the second argument to the .exec() callback will be undefined).

Warning: This is not recommended for update/destroy queries that affect large numbers of records.

usage
.fetch()

Usage

This method doesn't accept any arguments.

Example

javascript
var newUser = await User.create({ fullName: 'Alice McBailey' }).fetch();
sails.log(`Hi, ${newUser.fullName}!  Your id is ${newUser.id}.`);

Notes

<docmeta name="displayName" value=".fetch()"> <docmeta name="pageType" value="method">