node.js - How to get large data via mongoose non-blocking? -
node.js - How to get large data via mongoose non-blocking? -
how big collection via mongoose way, every document returned, not huge array whole collection?
at moment using next query:
var query = templatedata.find({}); query.exec(function (err, docs) { // docs array });
this way, query function blocking io , not non-blocking. there way create more non-blocking?
well, since took @ mongoose documentation after posting question, got on stream()
function, fullfills non-blocking operations perfectly.
blame me, think mentioned bit more offensive in mongoose documentation: http://mongoosejs.com/docs/api.html#query_query-stream
var query = templatedata.find({}).stream(); query.on('data', function (doc) { // mongoose document }).on('error', function (err) { // handle error }).on('close', function () { // stream closed });
node.js mongodb mongoose blocking nonblocking
Comments
Post a Comment