mongorestore command replace existing records?

前端 未结 4 1955
孤城傲影
孤城傲影 2021-01-01 10:29

Is there a way for mongorestore to replace the records existing in the database instead of skipping it which is the default behavior ?

I\'m currently using the lates

4条回答
  •  感情败类
    2021-01-01 10:50

    If you have a small collection you could always:

    1. mongodump your target collection somewhere else
    2. delete your target collection
    3. mongorestore the original dump file
    4. mongorestore the dump file you made in step 1

    This switches the precedence to your dump file instead of to the _ids in the DB.

提交回复
热议问题