As far as I see all commands operate on the same database in mongodb. I want to do something like this:
db.mySourceCollection.find().forEach( function(x){ db.theDestinationCollection.save(x)} );
where mySourceCollection is on liveDatabase and theDestinationCollection is on testDatabase.
Use
use🙂dbis used to refer to the currently connected database, however you can switch databases on the fly using theusecommand, as I’ve shown above.Check out the
helpcommand in the shell — it mentions this command and much more!