PersistedModel has a large set of methods for creating, updating, and deleting data.
Model data is also called a model instance; in database terminology, conceptually a model corresponds to a table, and a model instance corresponds to a row or record in the table.
Note: For information on model read operations, see Querying data.
Use the following PersistedModel methods to add data, that is to insert or create instances:
findOrCreate - Find one instance matching the filter object provided as the first parameter. If found, returns the object. If not found, creates a new instance (record).
Important:
Be sure to include a where clause in the filter object.
Without the where, the findOrCreate finds and returns the first record in the collection, without error, which can lead to unintended behavior.
</div>
Static method (called on the Model object):
Important:
The where clause used with updateAll() is slightly different than that for queries. Omit { where : ... } from the where clause.
Simply provide the condition as the first argument.
For more information, see Where filter.
Instance methods (called on a single model instance):
REVIEW COMMENT from Rand
Describe why you would perform bulk updates. Used with sync, for example.</div>
Static methods (called on the Model object):
Important:
The where clause with destroyAll() is slightly different than that for queries. Omit { where : ... } from the where clause. Simply provide the condition as the first argument.
For more information, see Where filter.