Mongo DB find by field name with any value

前端 未结 2 1816
栀梦
栀梦 2020-12-10 12:14

I am trying to find all documents that have this field, it doesn\'t matter what exact value it contains; I am only interested in the existence of it.

Here is an exam

2条回答
  •  一个人的身影
    2020-12-10 12:30

    You're probably looking for the $exists operator:

    db.collection.find({ "payload.discount": { $exists: true } })
    

提交回复
热议问题