mongoose-repl
Advanced tools
Comparing version 0.0.1 to 0.0.2
#!/usr/bin/env node | ||
// Generated by CoffeeScript 1.6.3 | ||
var argv, mongo_uri, path, schemas, shell, _ref, _ref1; | ||
var argv, mongo_uri, path, repl, schemas, _ref, _ref1; | ||
path = require('path'); | ||
shell = require('./lib-js/mongoose-repl'); | ||
repl = require('./lib-js/mongoose-repl'); | ||
@@ -20,2 +20,2 @@ argv = require("optimist").usage('mongoose [options] <mongo url>').options({ | ||
shell.run(schemas, mongo_uri); | ||
repl.run(schemas, mongo_uri); |
// Generated by CoffeeScript 1.6.3 | ||
var argv, mongo_uri, path, schemas, shell, _ref, _ref1; | ||
var argv, mongo_uri, path, repl, schemas, _ref, _ref1; | ||
path = require('path'); | ||
shell = require('./lib-js/mongoose-repl'); | ||
repl = require('./lib-js/mongoose-repl'); | ||
@@ -19,2 +19,2 @@ argv = require("optimist").usage('mongoose [options] <mongo url>').options({ | ||
shell.run(schemas, mongo_uri); | ||
repl.run(schemas, mongo_uri); |
// Generated by CoffeeScript 1.6.3 | ||
var CoffeeScript, mongoose, node_repl, util, vm, _; | ||
var CoffeeScript, magic_cb, mongoose, node_repl, util, vm, writer, _, | ||
__slice = [].slice; | ||
@@ -24,2 +25,27 @@ node_repl = require('repl'); | ||
writer = function(val) { | ||
var _ref; | ||
val = (_ref = val != null ? typeof val.toObject === "function" ? val.toObject() : void 0 : void 0) != null ? _ref : val; | ||
return util.inspect(val, { | ||
depth: null, | ||
colors: true | ||
}); | ||
}; | ||
magic_cb = function(context) { | ||
return function() { | ||
var err, other, res; | ||
err = arguments[0], res = arguments[1], other = 3 <= arguments.length ? __slice.call(arguments, 2) : []; | ||
if (err != null) { | ||
return console.error(err); | ||
} else { | ||
console.log(writer(res)); | ||
context._ = res; | ||
if (!_.isEmpty(other)) { | ||
return console.log('other cb args:', _.map.apply(_, __slice.call(other).concat([writer]))); | ||
} | ||
} | ||
}; | ||
}; | ||
module.exports.run = function(schemas, mongo_uri) { | ||
@@ -34,2 +60,4 @@ var conn, models, options; | ||
options = { | ||
useColors: true, | ||
writer: writer, | ||
"eval": function(cmd, context, filename, cb) { | ||
@@ -48,3 +76,5 @@ var err, js, res; | ||
if (res instanceof mongoose.Query) { | ||
return res.exec(cb); | ||
return res.exec(function(err, doc) { | ||
return cb(null, doc); | ||
}); | ||
} else { | ||
@@ -62,3 +92,4 @@ return cb(null, res); | ||
_.extend(repl.context, { | ||
conn: conn | ||
conn: conn, | ||
magic: magic_cb(repl.context) | ||
}); | ||
@@ -65,0 +96,0 @@ return repl.on('exit', function() { |
{ | ||
"name": "mongoose-repl", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A Mongo REPL with the full power of Mongoose", | ||
@@ -5,0 +5,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12945
172