Clone a collection in MongoDB

后端 未结 8 534
有刺的猬
有刺的猬 2020-12-02 10:19

I want to clone a MongoDB collection and save it on the same server with a different name. So for example right now I have the following collections: demo1.categories, demo1

相关标签:
8条回答
  • 2020-12-02 11:10

    there already has a command for this.

    Copy a single collection from one server to another. http://www.mongodb.org/display/DOCS/cloneCollection+Command

    0 讨论(0)
  • 2020-12-02 11:15

    Don't use db.cloneCollection() method, it is depreciated from the current version 4.2 instead try to use mongoexport.

    depreciated collection method

    0 讨论(0)
提交回复
热议问题