Mongo: query by key one level deep

前端 未结 1 732
感情败类
感情败类 2021-02-07 03:16

Is it possible to use something like \'exists\' in a Mongo query to return this record based on an ID?

Something like select where \'ids\' contains key \'123456\'

1条回答
  •  再見小時候
    2021-02-07 04:10

    As you're searching for the existence of a field with a given name, $exists is the operator you need (see Advanced Queries).

    e.g. something like:

    db.YourCollection.find({ "ids.123456" : {$exists: true}});
    

    0 讨论(0)
提交回复
热议问题