2

Is there anyway to check documents which contains an array field with more than 0 elements?

I mean,

{
   "_id": "sdfsf",
   code: "code",
   array: ["any", "any2"]
}

I would like to get any documents where document.array size is gt 0.

Any ideas?

Jordi
  • 20,868
  • 39
  • 149
  • 333
  • https://stackoverflow.com/questions/7811163/query-for-documents-where-array-size-is-greater-than-1 – David Dec 07 '18 at 09:39
  • You can use $expr with mongodb 3.6 and above... Something like `db.collection.find({ $expr: { $gt: ["$array", 0]} })` – Ashh Dec 07 '18 at 09:57

0 Answers0