I have collection of Users
with unique property UserName
. I need to insert
in this collection array of Users. But if UserNames
are equal
I need to replace
old document with the new one. (for each user)
Can be done this by one operation?
Asked
Active
Viewed 72 times
0

Ravi Shankar Bharti
- 8,922
- 5
- 28
- 52

Astemir Almov
- 396
- 2
- 16
-
Possible duplicate of [MongoDB update many if exist and create if not. Node API](http://stackoverflow.com/questions/43218310/mongodb-update-many-if-exist-and-create-if-not-node-api) – Mikey Apr 18 '17 at 14:23
-
1Yeah they are doing the same thing but NOT with one operation. They essentially used a loop of queries – itsundefined Apr 18 '17 at 14:24
-
1Possible duplicate of [Bulk upsert in MongoDB using mongoose](http://stackoverflow.com/questions/25285232/bulk-upsert-in-mongodb-using-mongoose) – ponury-kostek Apr 18 '17 at 14:41