Skip to content

Commit

Permalink
updated mongojs
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfil committed Dec 3, 2015
1 parent a67eb45 commit 24ed78c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
22 changes: 5 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ var async = require('async');
var DUPLICATE_KEY_ERROR = 11000;

function run(opts, cb) {
if (!(opts && opts.uriFrom && opts.uriTo && opts.data)) {
throw 'uriFrom|uritTo|data options are missing';
}

var collections = Object.keys(opts.data);
var dbFrom = mongojs(opts.uriFrom, collections);
var dbTo = mongojs(opts.uriTo, collections);
var dbFrom = mongojs.viaNative(opts.dbFrom.uri, opts.dbFrom.options, collections);
var dbTo = mongojs.viaNative(opts.dbTo.uri, opts.dbTo.options, collections);

var report = {};
log('copying..');
Expand All @@ -21,8 +17,8 @@ function run(opts, cb) {
});

function runOne(colName, cb) {
var colFrom = deepValue(dbFrom, colName);
var colTo = deepValue(dbTo, colName);
var colFrom = dbFrom[colName];
var colTo = dbTo[colName];
var query = opts.data[colName].query || {};
var transform = opts.data[colName].transform;

Expand Down Expand Up @@ -85,14 +81,6 @@ function run(opts, cb) {
opts.log && console.log.apply(this, [' '].concat([].slice.call(arguments)));
}

function deepValue(obj, path){
var res = obj;
var nodes = path.split('.');
for (var i = 0; i < nodes.length; i++) {
res = res[nodes[i]];
}
return res;
}
}

module.exports = run;
module.exports = run;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mongocopy",
"version": "0.0.7",
"version": "0.1.0",
"description": "module for copying the subsets of data between mongo databases",
"main": "index.js",
"scripts": {
Expand All @@ -18,7 +18,7 @@
"author": "bubenshchykov",
"license": "ISC",
"dependencies": {
"mongojs": "^0.13.0",
"mongojs": "git://github.com/debitoor/mongojs#v1.0.3",
"async": "^0.9.0"
},
"devDependencies": {
Expand Down

0 comments on commit 24ed78c

Please sign in to comment.