-
Type:
Bug
-
Resolution: Cannot Reproduce
-
Priority:
Major - P3
-
None
-
Affects Version/s: 3.6.9
-
Component/s: mongoimport
-
None
Insert a new document in MongoDB
Example:
db.collection.insert({"type":"Test","uid":"sampleUID", "items":[]})
Use mongoimport tool to import a JSON file (test.json) which has a record for the same sampleUID and type Test
{"type":"Test","uid":"sampleUID", "items":[{"itemId":"1234","itemId":"4444"]}
mongoimport --db dbName -c collectionName --mode upsert --upsertFields uid,type --type json --file test.json
Result:
Two documents present in MongoDB for the same uid and type
{"_id" : ObjectId("5b6c3df492edb6fcb616feb7"),"type":"Test","uid":"sampleUID", "items":[{"itemId":"1234","itemId":"4444"]} {"_id" : ObjectId("5b6c3df492edb6fcb616feb6"),"type":"Test","uid":"sampleUID", "items":[]}
Expected:
This was an upsert operation, so the original empty list should have been updated instead of creating a new list