Thursday 15 May 2014

node.js - Mongoose parse error -



node.js - Mongoose parse error -

i trying query collection 2000000 entries:

var tagschema = mongoose.schema({ tag: string, book: mongoose.schema.types.objectid }, { collection: 'tags' }); var tag = mongoose.model('tag', tagschema); tag.count({}, function( err, count){ console.log( "number of tags:", count ); }); tag.find({}, function( err, count){ console.log(count) console.log(err) }).sort({'_id': 1}).limit(10);

tag.count returns number of documents expected, getting error when trying access documents 'find'

the error [error: parseerror occured]

any ideas?

make sure set query limit/sort/filter method calls before executes.

tag.find({}).sort({'_id': 1}).limit(10).exec(function(err, tags) { console.log(err, tags); });

in version since provide callback find mongoose runs query , calls limit , sort late take effect.

node.js mongoose

No comments:

Post a Comment