Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • MongoDB : $exist and $type operator

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 996
    Comment on it

    MongoDB - $exist and $type operator

    $type operator : It matches values based on their BSON type.

    e.g. We want to fetch documents from the collection which contains the value of "city" is only null.

    db.collection.find( { "city" : { $type : 10 } } ).pretty();
    

    Above query return city with null value.

    $exist operator : It matches whether the particular field exist or not in collection.

    e.g. We want to fetch documents from the collection which does not contain the "city" column.

    db.collection.find( { "city" : { $exists : false } } ).pretty();
    

    Above query return records which have not city column.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: