0

Suppose I have the following item structure:

"_id": "12325523623453254",
  "blas": {
    "blaA": 0,
    "blaB": 0,
    "blaC": 0,
    "blaD": 1,
  }
}

I like to find the items with "blas" including at least one non zero value.

Rahul
  • 15,264
  • 3
  • 40
  • 61
erogol
  • 12,388
  • 30
  • 95
  • 151

1 Answers1

0

You can do this with an $or query that uses dot notation in the keys to access the fields within blas:

db.test.find({$or: [
    {'blas.blaA': {$ne: 0}},
    {'blas.blaB': {$ne: 0}},
    {'blas.blaC': {$ne: 0}},
    {'blas.blaD': {$ne: 0}}
]})
JohnnyHK
  • 290,447
  • 61
  • 595
  • 453