In MongoDB, operators are used to perform various operations in queries, updates, aggregations, and other operations.
These operators enable us to manipulate data in the database in various ways.
$eq: Matches values that are equal to a specified value.
$ne: Matches values that are not equal to a specified value.
$gt: Matches values that are greater than a specified value.
$gte: Matches values that are greater than or equal to a specified value.
$lt: Matches values that are less than a specified value.
$lte: Matches values that are less than or equal to a specified value.
$and: Joins query clauses with a logical AND and returns all documents that match the conditions of both clauses.
$or: Joins query clauses with a logical OR and returns all documents that match the conditions of either clause.
$not: Inverts the effect of a query expression and returns documents that do not match the query expression.
$exists: Matches documents that contain the specified field.
$type: Selects documents if a field is of the specified type.
$in: Matches any of the values specified in an array.
$nin: Matches none of the values specified in an array.
$all: Matches arrays that contain all elements specified in the query.
$set: Sets the value of a field in a document.
$unset: Removes the specified field from a document.
$inc: Increments the value of a field by a specified amount.
$push: Adds an element to an array.
$addToSet: Adds elements to an array only if they do not already exist in the set.
$group: Groups documents by a specified expression and applies accumulator expressions to each group.
$sum, $avg, $min, $max: Accumulator expressions used within the $group stage.
$project: Reshapes documents by including, excluding, or adding fields.
$unwind: Deconstructs an array field from the input documents to output a document for each element.