Model Class Delete Functions numeric model
Deletes all records that match the
By default, objects will not be instantiated and therefore callbacks and validations are not invoked.
You can change this behavior by passing in
Returns the number of records that were deleted.
|where||string||No||Maps to the
|include||string||No||Associations that should be included in the query using
|instantiate||boolean||No||false||Whether or not to instantiate the object(s) first. When objects are not instantiated, any callbacks and validations set on them will be skipped.|
|transaction||string||No||[runtime expression]||Set this to
// Delete all inactive users without instantiating them (will skip validation and callbacks). recordsDeleted = model("user").deleteAll(where="inactive=1", instantiate=false); // If you have a `hasMany` association setup from `post` to `comment`, you can do a scoped call. (The `deleteAllComments` method below will call `model("comment").deleteAll(where="postId=#post.id#")` internally.) post = model("post").findByKey(params.postId); howManyDeleted = post.deleteAllComments();