Guest User

Untitled

a guest
Nov 8th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. function copydb(_sourceUrl, _destinationUrl, _db, _sourceAdminUsername, _sourceAdminPassword) {
  2. return new Promise((resolve, reject) => {
  3. mongoClient.connect(_destinationUrl + "/" + _db)
  4. .then(destinationDB => {
  5. destinationDB.admin().command({
  6. copydb: 1,
  7. fromhost: _sourceUrl,
  8. fromdb: _db,
  9. username: _sourceAdminUsername,
  10. todb: _db,
  11. nonce: "some-nonce",
  12. key: {
  13. username: _sourceAdminUsername,
  14. password: _sourceAdminPassword
  15. }
  16. }, function (err, res) {
  17. if (err) {
  18. reject(err)
  19. } else {
  20. resolve(res)
  21. }
  22. destinationDB.close();
  23. })
  24. }).catch(err => reject(err))
  25. })
Add Comment
Please, Sign In to add comment