MongoDB, select all entries where inner data-count is greater then zero -


i have one.

{     "title" : "",     "source" : {         "object" : "some",         "group" : "some         "data" : []     } } 

"source.data" or "source" can undefined @ all.

so need select objects has count(xxx.source.data) > 0 . how can query? search count() , xxx.length (method\property) still can't understand how use them in case.

added:

.find({"source.data": {$exists: true, $size: {$gt: 1}}}) 

you can follows :

db.myobject.find({$and:[{"source.data":{$exists:true}},{"source.data":{$not:{$size:0}}}]}) 

from mongodb documentation, says $size operator not accept range queries.

$size not accept ranges of values. select documents based on fields different numbers of elements, create counter field increment when add elements field.

for greater queries, can use list index. can use following query find documents has data size > 10.

db.myobject.find({$and:[{"source.data":{$exists:true}},{"source.data.10" : {$exists:true}}]}) 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -