Skip to content

Instantly share code, notes, and snippets.

View dineshsdm's full-sized avatar
💭
No legacy is so rich as honesty

Dinesh Kumar dineshsdm

💭
No legacy is so rich as honesty
View GitHub Profile
@RandomEtc
RandomEtc / mongo_import.js
Created September 15, 2011 16:04
use node.js to copy from one mongo db to another
var url = require('url'),
mongodb = require('mongodb');
var sourceUrl = 'mongodb://user:pass@host:port/db',
targetUrl = 'mongodb://user:pass@host:port/db',
collectionName = 'my_awesome_collection';
function openDbFromUrl(mongoUrl, cb) {
var dbUrl = url.parse(mongoUrl),
dbName = dbUrl.pathname.slice(1), // no slash