Clone database in Mongodb between hosts using node driver

后端 未结 2 1698
青春惊慌失措
青春惊慌失措 2020-12-21 16:19

There are clone and copydb commands available in mongo shell, how to reach them in mongo node native driver(mongodb)?

That\'s what I have tried:

I discovered

2条回答
  •  天命终不由人
    2020-12-21 16:51

    dude, you should essentially just try

    use admin;
    
    db.runCommand({
      copydb: 1,
      fromhost: "myhost",
      username:"azureuser",
      fromdb: "test",
      todb: "test"
    })
    

    All mongo asking for is the switch to "admin" db before running such a command, and then it will run fine.

提交回复
热议问题