Last active
August 29, 2015 14:06
-
-
Save davehughes/673f3da89d05aff26cf4 to your computer and use it in GitHub Desktop.
Nesh shell initialization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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