I want to carry out some as follows in MongoDB using Mongoose, is it possible?
const id = "5fjsjbvjbsdvjhkn6763287";
const arr = ["Hello", "World"]
await User.findByIdAndUpdate(
id,
{
$addToSet: {
arrayField: arr
}
}
);
Basically, adding an array to an array field and making sure the array is of unique elements.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…