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
--drop
remove the whole collection before importing the data from the json file, while--mode=upsert
insert the new keys and updates the existing ones. – Neurovascular