Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function copydb(_sourceUrl, _destinationUrl, _db, _sourceAdminUsername, _sourceAdminPassword) {
- return new Promise((resolve, reject) => {
- mongoClient.connect(_destinationUrl + "/" + _db)
- .then(destinationDB => {
- destinationDB.admin().command({
- copydb: 1,
- fromhost: _sourceUrl,
- fromdb: _db,
- username: _sourceAdminUsername,
- todb: _db,
- nonce: "some-nonce",
- key: {
- username: _sourceAdminUsername,
- password: _sourceAdminPassword
- }
- }, function (err, res) {
- if (err) {
- reject(err)
- } else {
- resolve(res)
- }
- destinationDB.close();
- })
- }).catch(err => reject(err))
- })
Add Comment
Please, Sign In to add comment