In MongoDB, you can use the $subtract
aggregation pipeline operator to subtract numbers and/or dates.
Tag: what is
MongoDB $add
In MongoDB, the $add
aggregation pipeline operator adds values together. Such values can be numbers, or they can be numbers and a date.
The $add
operator accepts the values as arguments. The arguments can be any valid expression as long as they resolve to either all numbers or to numbers and a date.
MongoDB $anyElementTrue
In MongoDB, the $anyElementTrue
aggregation pipeline operator evaluates an array as a set and returns true
if any of the elements are true
.
If none of the elements is true
, then it returns false
.
An array’s element is true
if it’s not false
, null
, 0
, or undefined
.
MongoDB $allElementsTrue
In MongoDB, the $allElementsTrue
aggregation pipeline operator evaluates an array as a set and returns true
if no element in the array is false
.
If the array contains an element that is false
, then $allElementsTrue
returns false
.
An array’s element is true
if it’s not false
, null
, 0
, or undefined
.
About the GO Command in SQL Server
If you’ve used T-SQL you will probably be familiar with the GO
command. This command is often placed at the end of a batch of statements.
MongoDB $push vs $addToSet: What’s the Difference?
MongoDB has a $push
operator and an $addToSet
operator, both of which do a very similar thing.
Both operators append values to an existing array. The main difference is in how they deal with arrays that already contain the value you’re trying to append, and also in the modifiers that can be used.
Continue readingMongoDB $toUpper
In MongoDB, the $toUpper
aggregation pipeline operator converts a string to uppercase and returns the result.
MongoDB $toLower
In MongoDB, the $toLower
aggregation pipeline operator converts a string to lowercase and returns the result.
MongoDB $exists
In MongoDB, you can use the $exists
element query operator to match documents that contain a specific field.
You can also use it to match documents that don’t contain a specific field.
You can also use it in conjunction with other operators such $nin
to match documents where a given field exists, but it doesn’t contain a specific value.
MongoDB forEach()
In MongoDB, the cursor.forEach()
method iterates the cursor to apply a JavaScript function
to each document from the cursor.