$addToSet Operator in MongoDB
The $addToSet operator in MongoDB is used to add a value to an array and if the value already exists in the array, then this operator will do nothing.
The $addToSet operator appends the whole array as a single element if the value is an array. To add each element of the value separately, the $each modifier can be used with the $addToSet operator.
It is compatible with various MongoDB environments like MongoDB Atlas, MongoDB Enterprise, and MongoDB Community.
MongoDB $addToSet Operator
MongoDB $addToSet Operator adds a value to an array field in the document.
Contact Us