what i want, is to only return the _id and data in meta (not my field, but since mongoose has this prime example): mongoose embedd documents doc
so, i’m not looking for any _id in particular, i’m looking for records with meta.votes.length > 0 or meta.fans.length > 0. currently i do:
Model.find({}, ['_id','meta'], function (err, data) {
callback(null, data);
});
i get records with no /data/. i guess an alternative to not finding these sets would be a way to filter them out?
EDIT: i have temporarily resolved my issue with:
use : { type: Boolean, default: 1 },
though this might be a feature (showing and hiding results – old data for instance), i don’t consider this a /solution/.
Well
meta.votesandmeta.fansare both just Number objects so I don’t think you wantmeta.fans.lengthjust access them directly like an int.This query should retrieve just the _id and meta information for votes > 0
And this query should retrieve just the _id and meta information for fans > 0
And you could pull both queries together like this:
You should be seeing returns like:
{ _id: 5001b3ce7cf4b534a3000002, meta: { votes: 1, fans: 1 } }