Friday, March 30, 2012

MongoDB: copy collections


Recently I got involved in the node.js type of project, with MongoDB back-end. Last time I played with MongoDB was more than a year ago, so I'm pretty much refreshing my memory at this point.

Here is,  for example how to copy the data from one collection to another:

db.srcCollection.find().forEach( function(c){db.destCollection.insert(c)} )


1 comment:

Anonymous said...

awesome! thx for this quick fix