mongodb $exists always returning 0

后端 未结 2 1622
面向向阳花
面向向阳花 2020-12-11 17:38

I have a database collection (named fols) like so:

{\'followers\':
        {
           \'123\':1
           \'123\':2
           \'123\':3
         }
}
         


        
2条回答
  •  悲哀的现实
    2020-12-11 17:56

    When you're not matching a complete object you need to use dot notation to use an operator against an embedded object. So in this case:

    cursor = fols.find({'followers.123':{'$exists': True}})
    

提交回复
热议问题