node.js - Mongo Aggregation Framework with Mongoose raising Document Limit exception on simple Projection -


i have collection links (schema below) 500k entries.

 {    url,    title,    owner,    stars: { users: [{ name }]},    createdat  } 

and not understand why simple aggregation projection

var projection = { $project: { _id: 1, url: 1, title: 1, createdat: 1 } } link.aggregate([projection]).exec(resultcallback); 

raises

mongoerror: exception: aggregation result exceeds maximum document size (16mb) 

could explain me ?

i'm using mongoose (3.8.8) , mongodb (2.6.0)

not sure if options available mongodb 2.6 , on-wards available in .aggregate() method implementation in mongoose. there should options "hash/object" available after pipeline argument. basically:

var pipeline = [{ $project: { _id: 1, url: 1, title: 1, createdat: 1 } }]; link.aggregate(pipeline,{ cursor: true}, function(err,cursor) {  }); 

or if mongoose doesn't reason raw node driver collection:

var pipeline = [{ $project: { _id: 1, url: 1, title: 1, createdat: 1 } }]; link.collection.aggregate(pipeline,{ cursor: true}, function(err,cursor) {     if (err)       throw err;     // cursor more akin node    // stream interface basic .next() method , other helpers.  }); 

otherwise since output blowing 16mb bson limit can output collection:

var pipeline = [     { $project: { _id: 1, url: 1, title: 1, createdat: 1 } },     { $out: "newcollection" } ]; 

but since testing, why not use $limit pipeline stage until work out rest of aggregation:

var pipeline = [     { $project: { _id: 1, url: 1, title: 1, createdat: 1 } },     { $limit: 50 } ]; 

so there few different ways handle things.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -