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

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -