i have an array of documents in mongodb like this

There is a syntax error.

.update({productId : 19}, {$addToSet :{
                    languageCode : "ar",
                    languageId : 2,
                    productId : ObjectId("5f9aab1c8e475489270ebe2f")
                } } })

You have to use the operator first than the field name.

Note the switched order of addToSet and field references

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top