Skip to content

Instantly share code, notes, and snippets.

@davehughes
Last active August 29, 2015 14:06
Show Gist options
  • Save davehughes/673f3da89d05aff26cf4 to your computer and use it in GitHub Desktop.
Save davehughes/673f3da89d05aff26cf4 to your computer and use it in GitHub Desktop.
Nesh shell initialization
// Exports to Nesh shell
// + Add a shell alias 'alias nesh="nesh --eval {this file}"' to automatically
// trick out your shell with these natural code enhancements.
__ = _ = require('lodash');
config = require('./common').config();
db = require('./models');
Q = require('q');
mongo = require('monk')(config.db.mongo.url);
function storePromiseResult(name, promise) {
/** Given a promise assign its results to the global variable `name`. */
promise.then(function(res) {
GLOBAL[name] = res;
}, console.log);
return 'Storing result -> ' + name;
}
function showQuery(queryResults) {
_.each(queryResults, function(result) {
console.log(result.values);
});
}
storeq = storePromiseResult;
showq = showQuery;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment