jsonmongodbmongoimport

Mongoimport json file update or overwritte ..?


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

Solution

  • For MongoDB v3.x,

    --mode=upsert