mongodbpymongo-3.x

pymongo $exists :false vs False


I am reading data from pymongo and need to check if column exists or not

[doc for doc in col.find{"IAM":{"$exists":false}}  

I am getting and error near false

I have tried to convert false to False, but in mongodb it is not returning anything. how to check if column exists in pymongo?


Solution

  • A few things to correct:

    So your final statement is:

    result = list(col.find({"IAM": {"$exists": False}}))  
    

    *In the mongo shell / javascript it is false (lowercase)