1

I am using Laravel-MongoDB query builder. A document of my collection(words) is below:

 {
    "_id" : ObjectId("58464564545yb45y45yf"),
    "word" : "Bird",
    "keys" : [ {"title": "t1"}, {"title": "t2"} ]
}

How do I find all documents where the field "keys" size is greater than 0 ?

shoeab
  • 186
  • 3
  • 9
  • http://stackoverflow.com/questions/7811163/query-for-documents-where-array-size-is-greater-than-1 – Shaishab Roy May 01 '17 at 15:31
  • Thanks Shaishab, I know how to do it in mongo. I asked to find out, how to do it using jenssegers' package Laravel-MongoDB. – shoeab May 01 '17 at 16:01

1 Answers1

3

After a few searching and according to the answer here: https://stackoverflow.com/a/42195574/2193751

I found this

$ords = Word::where('keys.0', 'exists', true)->get();

It works for me.

Community
  • 1
  • 1
shoeab
  • 186
  • 3
  • 9