Mongo DB find by field name with any value

前端 未结 2 1811
栀梦
栀梦 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:35

    There's a $exists operator for that:

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

提交回复
热议问题