I will go out on a limb here and say it sucks to have to write a bunch of
async code to load data in node. Many times we know exactly what we want to
load ahead of time. Why can't we just declare all the things we want to
load and then load it all at once? For example, with two mongo collections:
loader.add( {
contacts : {
fields : [ 'firstName', 'lastName' ],
where : { group: { $in: [ 'business', 'personal' ] } },
sort : { lastName : 1, firstName : 1 }
},
groups : {
fields : '*',
where : { label: { $in: [ 'business', 'personal' ] } }
}
} );
And then load them all at once with one simple async call?
loader.load( function( err, payload ) {
console.log( payload.contacts ); // array of contacts
console.log( payload.groups ); // array of groups
} );
We have found this paradigm especially useful when simply relaying JSON
data to a client. Wrote a song about it. Here it goes:
https://github.com/rotundasoftware/steamer
Anybody else experimenting with declarative approach to loading data?
David BEck
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.