I need to get total count of objects in the "photo" array field, and compare it to the value in "mls_media_count" field, so that I can detect when the values do not match.
open_houses:null
open_houses_lock:false
photos:Array
0:Object
1:Object
2:Object
3:Object
4:Object
5:Object
6:Object
7:Object
8:Object
9:Object
mls_media_count: 8
I have tried using $unwind, $project, $size, but haven’t had luck getting it to work.
Thanks in advance!
2
Answers
Thank you for response! This got me on right track and i ended up writing it like this:
Query
$size
can give the size of the array, and we can compare it with themedia_count
Playmongo
Playmongo