Mongodb: db.collection.copyTo() and eval() have been deprecated. What's the alternatives?

后端 未结 3 1251
猫巷女王i
猫巷女王i 2021-02-07 02:44

I find that db.collection.copyTo() and eval() have been deprecated since 3.0. But I do not find what can be instead.

What\'s the alternatives?

3条回答
  •  暖寄归人
    2021-02-07 03:05

    Create a mongodump of that collection, do mongorestore to a separate or new collection.

    This wont stop read/write or wont lock the collection.

    mongodump --db db-name --collection collection-name --archive=collection-name.archive
    

    or save as json both works

    If saved as archive, to restore

    mongorestore --db db-name --collection collection-name --archive=collection-name.archive
    

提交回复
热议问题