$addToSet
The $addToSet operation is used to add a value to an array field, ensuring that the value is unique within the array. If the specified value already exists in the array, it will not be added again, preventing duplicates. This operation is useful when maintaining a collection of unique elements without manually checking for duplicates before inserting new values.
Last updated