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

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 740
    Comment on it

    MongoDB - $in and $or operator

    $in operator : It match a value within the specified values within the given values.

    e.g. If we want to select record which credit score is (1200 and 2000).

    db.collection.find({"creditscore" :{$in :[1200,2000]}}).pretty();
    

    $or operator: It match whether any of the specified value is matching in the given records.

    e.g. If we want to select record which either belongs to color 'red' or grade 'C'.

    db.collection.find({$or : [ { "color" : 'red' } , { "grade" : "C" } ] } ).pretty();
    

 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: