Skip to main content
Version: v2.x.x

Queries

Queries

MethodDescriptionParameters
insert(data)Create a new document with the provided data.data: obj
create(data)Alias for the insert method.data: obj
insertMany(data)insertMany method used to insert documents into the database collection.data: obj[]
update(data)Update a single document that matches a given query.data: obj
updateMany(data)Update multiple documents that match a given query.data: obj
delete()Delete a single document that matches a given query.-
deleteMany()Delete multiple documents that matches a given query.-
destroy(ids)Delete one or multiple documents by idsids: id or id[]
select(columns)Select specific columns to be displayed in the query results.columns: str or str[]
exclude(columns)Exclude specific columns from being displayed in the query results.columns: str or str[]
all()Retrieve all of the records from the model's associated database collection.-
get(columns)Get the documents matching the query criteria.columns: str or str[]
first(columns)Get the first document matching the query criteria.columns: str or str[]
find(id)Find a document by its ID.id: str or ObjectId
pluck(column)Retrieve the values of a specific column from the query results.column: str
where(column, operator, value)Add a WHERE clause to the query.column: str, operator: str, value: any
orWhere(column, operator, value)Add an OR WHERE clause to the query.column: str, operator: str, value: any
whereIn(column, values)Add a WHERE IN clause to the query.column: str, values: any[]
orWhereIn(column, values)Add an OR WHERE IN clause to the query.column: str, values: any[]
whereNotIn(column, values)Add a WHERE NOT IN clause to the query.column: str, values: any[]
orWhereNotIn(column, values)Add an OR WHERE NOT IN clause to the query.column: str, values: any[]
whereBetween(column, values)Add a WHERE BETWEEN clause to the query.column: str, values: int[]
orWhereBetween(column, array values)Add an OR WHERE BETWEEN clause to the query.column: str, values: int[]
orderBy(column, direction?, isSensitive?)Sort the query results by a specific column.column: str, direction: str, isSensitive: bool
groupBy(column)Group the query results by specific columns.column: str

Paginations

MethodDescriptionParameters
limit(value)Limit the number of documents to be returned by the query.value: int
take(value)Alias for the limit method.value: int
offset(value)Set an offset for the query results.value: int
skip(value)Skip a specified number of documents in the query results.value: int
paginate(page, limit)Paginate the query results.page: int, limit: int

Aggregates

MethodDescriptionParameters
min(column)Retrieve the minimum value of a specific column.column: str
max(column)Retrieve the maximum value of a specific column.column: str
sum(column)Calculate the sum of values in a specific column.column: str
avg(column)Calculate the average value of a specific column.column: str
count()Count the number of documents matching the query criteria.-

Support us

Mongoloquent is an MIT-licensed open source project. It can grow thanks to the support by these awesome people. If you'd like to join them, please read more here.

Sponsors

_

Partners