Querying null value in MongoDB

后端 未结 2 968
执念已碎
执念已碎 2021-01-03 10:45

Using pymongo I am trying to retrieve the documents in a collection that have a SmallUrl different from null. I\'m trying to get t

2条回答
  •  长情又很酷
    2021-01-03 11:03

    The pymongo version of null is the Python None. So query should look like:

    query = {
        'Name': {'$regex': search_title, '$options': 'i'}, 
        'Images.SmallUrl': {'$ne': None}}
    

提交回复
热议问题