Mongoimport json file update or overwritte ..?

Mercer picture Mercer · Apr 21, 2015 · Viewed 14.1k times · Source

I'm having DB which name is "Project" and collection which name is "sample" then I inserted one JSON file using mongoimport command.

Now i edited the same JSON file. So if want to import the same JSON file to the Collection then I am facing the problem like multiple instances are created and no updating is not taking place.

Is there any way to update or overwrite the data already present in the mongodb using mongoimport command ?

Note that I also tried using --mode=upsert flag:

./mongoimport --db Project --collection sample --mode=upsert --file   /home/rule.json

Answer

lanenok picture lanenok · Apr 21, 2015

For MongoDB v3.x,

--mode=upsert