Skip to content

Instantly share code, notes, and snippets.

@balkian
Last active August 29, 2015 14:17
Show Gist options
  • Save balkian/25131ca85f4f86c8d57c to your computer and use it in GitHub Desktop.
Save balkian/25131ca85f4f86c8d57c to your computer and use it in GitHub Desktop.
Copy one collection from a database to another in the same MongoDB
db.<collection_name>.find().forEach(function(d){ db.getSiblingDB('<new_database>')['<collection_name>'].insert(d); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment