.destroy()

Destroy records in your database that match the given criteria.

await Something.destroy(criteria);

Or:

var destroyedRecords = await Something.destroy(criteria).fetch();

Usage

Argument

Type

Details

1

criteria

Records which match this Waterline criteria will be destroyed. Be warned, if you specify an empty dictionary ({}) as your criteria, all records will be destroyed!destroy queries do not support pagination using skip and limit or projections using select.

Result

Type

Description

of

For improved performance, the destroyed records are not provided as a result by default. But if you chain .fetch(), then the destroyed records will be sent back. (Be aware that this requires an extra database query in some adapters.)

Notes

If you want to confirm that one or more records exist before destroying them, you should first perform a find(). However, keep in mind it is generally a good idea to try to do things rather than checking first, lest you end up with a race condition.

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-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Built with Love

The Sails framework is maintained by a web & mobile studio in Austin, TX, with the help of our contributors. We created Sails in 2012 to assist us on Node.js projects. Naturally we open-sourced it. We hope it makes your life a little bit easier!