I'm trying to clone a mongodb collection with the indexs from two different MongoDB instances. After googling around, I found that cloneCollection would be my best bet. I've tried to make my code nice and simple, but I never seem to get the actual clone command to run. 'Started' and 'Authed' pop up in my console, but the command never runs. What is it I'm doing wrong? Thanks.
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