From 6d47c4b9e27afed9b66b051d83bf250a7e406d9d Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 24 Nov 2018 10:31:01 +0100 Subject: [PATCH] docs(sails): add updateOne, destroyOne and archiveOne --- backend/sails.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backend/sails.js b/backend/sails.js index b0e17d8..0b61e28 100644 --- a/backend/sails.js +++ b/backend/sails.js @@ -492,6 +492,10 @@ MyModel.replaceCollection() // saving them as new records in the built-in Archive model, then destroying the originals. MyModel.archive(criteria) +// Archive ("soft-delete") the record that matches the specified criteria, +// saving it (if it exists) as a new record in the built-in Archive model, then destroying the original. +MyModel.archiveOne(criteria); + // Get the total number of records matching the specified criteria. MyModel.count(criteria) @@ -523,10 +527,16 @@ MyModel.createEach(initialValues).fetch() // Created records will be returned MyModel.update(criteria, valuesToSet) MyModel.update(criteria, valuesToSet).fetch() // Updated records will be returned +// Update the record that matches the given criteria, if one exists. +MyModel.updateOne(criteria).set(valuesToSet); + // Destroy records in your database that match the given criteria. MyModel.destroy(criteria) MyModel.destroy(criteria).fetch() // Destroyed record will be returned +// Destroy the record in your database that matches the given criteria, if one exists. +MyModel.destroyOne(criteria); + // Access the datastore for a particular model. MyModel.getDatastore()