我正在尝试使用来自两个不同MongoDB实例的索引克隆mongodb集合。谷歌搜索后,我发现cloneCollection是我最好的选择。我试图让我的代码变得简单明了,但我似乎从来没有得到实际的克隆命令来运行。在我的控制台中弹出'Started'和'Authed',但命令永远不会运行。我做错了什么?感谢。
mongodb = require("mongodb")
#####################
# MONGODB CONFIG
#####################
console.log "Started"
Server = mongodb.Server
Db = mongodb.Db
server = new Server("example.com", 27017, {})
db = new Db("databaseTwo", server,
safe: true
)
db.open (err, db) ->
db.authenticate "user", "password", (err, res) ->
throw err if err
console.log "Authed"
db.command
cloneCollection: "databaseOne.helloThereCollection"
from: "example.com:6001"
key:
username: 'user'
password: 'password'
, (err, cb) ->
console.log err if err
console.log 'Command Ran'
cb null