Persists the current changes to the database.
Example
const post = new Post();
post.title = 'My Second Blog Post!';
await post.save();
Returns all models.
Example
const posts = await BlogPost.all();
Creates a new model with the given attributes. The Id will be automatically generated if none is provided.
Example
const post = await BlogPost.create({ title: 'My First Blog Post!' });
Returns the model with the given id.
Example
const post = await BlogPost.find('5f5a41cc3eb990709eafda43');
Returns the first model matching where the key
matches value
.
Example
const user = await User.findBy('email', 'john.smith@company.com');
Limits the number of models returned.
Specifies the order the models are returned.
Example
const posts = await BlogPost.orderBy('publishedAt', 'desc').get();
Returns a QueryBuilder where key
matches value
.
Example
const posts = await BlogPost.where('status', 'published').get();
Returns models where key
is in the array of values
.
Example
const comments = await Comment.whereIn('postId', [1, 2, 3]).get();
Generated using TypeDoc
Deletes the model from the database.
Example
await post.delete();