Returns the number of documents matching the given query.
Example
const numberOfPayingCustomers = await Customer.where('hasPaidTheLastInvoice', true).count();
Creates a new document with the given attributes.
Deletes the Models matching the current query options.
Returns the number of models deleted.
Returns the model with the given id or null if there is no matching model.
Returns the first model matching the query options.
Returns the first model matching the query options.
Returns an array of models matching the query options.
Limits the number of models returned.
Returns the largest value for the given key.
Returns the smallest value for the given key.
Sorts the models by the given key.
The key you want to sort by.
Defaults to ascending order.
Returns the nth percentile of all the values for the given key.
The pluck method retrieves all of the values for a given key.
You may also specify how you wish the resulting collection to be keyed.
Example
await Posts.where('categoryId', 2).pluck('id');
// => [ '1', '2', '3' ]
await Products.where('size', 'large').pluck('price', 'name');
// => [ { name: 'Shirt 1', price: 14.99 } ]
Persist the provided attributes.
Returns the sum of all the values for the given key.
Adds a constraint to the current query.
Returns all the models with fieldName
in the array of values
.
Generated using TypeDoc
Returns the average of all the values for the given key.