mongodb - Count occurences and store IDs of not-empty multiple specific fields -
i have simple find
query finds documents either first field not null, or second field not null
looks this:
db.registries.find({ "$or": [ { "field1": { "$ne": null } }, { "field2": { "$ne": null } } ] }, { "field1": 1, "field2": 1 })
then, on result, in javascript, i'm doing filter
, map
on array(result) i'm checking occurences of field1
, field2
, dividing them 3 arrays ids(objectids), 1 field1
not being null, 2nd field2
not being null , 3rd both fields not null
i discovered using count
instead of find
lot faster, doesn't give me want, divide them 3 arrays, storing there ids
is there way can speed find
or use count
instead, gives me output want?
Comments
Post a Comment