Clone database in Mongodb between hosts using node driver

后端 未结 2 1683
青春惊慌失措
青春惊慌失措 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.

    0 讨论(0)
  • 2020-12-21 17:00

    Have you tried using db.admin().command?

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