Using mongoose's Model.aggregate() returns an empty array.
I've essentially copied the format as seen here.
var match = {};
var project = {};
project["_id"] = 0;
project["products.totalprice"] = 1;
project["line"] = "$products.closedate";
ThisCollection.aggregate([
{$match: match},
{$project: project},
{$group: {
_id: "$line"
}}
], function(err, docs){
console.log(docs); //!! Returning []
});
My schema is essentially a name and _id field with a nested array of products with totalprice, closedate and some other fields.
There are most certainly a plethora of entries (some 130,000 records). Can anyone spot an issue with this?
$groupstatement return any results ?projectobject, I'm now gettingundefinedfor docs.