Answer the question
In order to leave comments, you need to log in
How to prevent duplication in an array?
Is it possible to prevent the same IDs from being added to the array? Added { unique: true, dropDups: true } , but it doesn't help. Perhaps I am passing this option incorrectly.
Tell me, please, what to change?
Project.updateOne(
{ _id: req.params.projectId },
{
$push: { developers: req.body.developer.devId },
},
{ unique: true, dropDups: true }
);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question