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

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -