findOneAndUpdate causing duplication problem
问题 I am having a problem in findOneAndUpdate in mongoose. The case is that i am updating a document by finding it. The query is as follows: UserModel.findOneAndUpdate({ individualId: 'some id' }, { $push: { supporterOf: 'some string' } }) The 'supporterOf' is the ref of UserModel and its type is 'ObjectId'. The issue i am facing here is that, 'some string' is being pushed twice under 'supporterOf' in the document. Can anyone tell me that how to push an array element inside the document? 回答1: I