Skip to content

Instantly share code, notes, and snippets.

@heymichaelp
Created July 16, 2014 22:50
Show Gist options
  • Save heymichaelp/c0f4d145c5f1293c1c06 to your computer and use it in GitHub Desktop.
Save heymichaelp/c0f4d145c5f1293c1c06 to your computer and use it in GitHub Desktop.
var utensils = require('./lib/utensils');
var Query = utensils.Query;
var db = require('./db');
var Q = require('q');
var ActiveAccountsQuery = Query.extend({
db: db,
collectionsNames: [
'accounts',
'cars'
],
procedure: [
'getAccounts',
'somethingAsync'
],
getAccounts: function() {
return Q.ninvoke( this.collections.accounts, 'find' )
.then( this.toArray );
},
somethingAsync: function( accounts ) {
return Q.ninvoke( this.collections.cars, 'find')
.then( this.toArray );
}
});
new ActiveAccountsQuery().perform()
.then(function( documents ){ console.log( 'done', documents ); })
.fail(function( errors ){ console.log('fail', arguments ) });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment