MongoDB Set Operators
MongoDB set operators are a group of special operators used to manipulate collection-type fields, including set union, set difference, set intersection, etc. They can be used for various operations on sets in both aggregation queries and regular queries. This page lists the set operators available in MongoDB.
-
$allElementsTrue
$allElementsTrueis a logical operator in MongoDB used to test whether all elements in an array field are true. -
$anyElementTrue
$anyElementTrueis an operator in MongoDB’s query language used to match array fields that contain at least one element that istrue. -
$setDifference
The MongoDB$setDifferenceoperator is one useful operator that is used to get the different elements between two collections. -
$setEquals
$setEqualsis a set operator in MongoDB that can be used to compare whether two sets are equal. -
$setIntersection
$setIntersectionis an array operator in MongoDB that returns the intersection of two arrays. -
$setIsSubset
$setIsSubsetoperator is an array operator in MongoDB, used to determine if an array is a subset of another array, and returns a Boolean value. -
$setUnion
$setUnionis an aggregation operator in MongoDB that merges two arrays into a single array and removes duplicates.