MongoDB Basics: Chapter 4: Advanced CRUD Operations - Query Operators: Comparison


No Action
1
MongoDB Basics: Chapter 4: Advanced CRUD Operations Query Operators - Comparison

0 comment

21 December 2020, 6:56 am by antelove19

MongoDB Basics: Chapter 4: Advanced CRUD Operations - Query Operators: Comparison
MongoDB Basics: Chapter 4: Advanced CRUD Operations - Query Operators: Comparison

This lesson used the following commands: Connect to the Atlas cluster: ```javascript mongo "mongodb+srv://:@.mongodb.net/admin" ```
Switch to this database: ```javascript use sample_training ```
Find all documents where the tripduration was less than or equal to 70 seconds and the usertype was not Subscriber: ```javascaript db.trips.find({ "tripduration": { "$lte" : 70 }, "usertype": { "$ne": "Subscriber" } }).pretty() ```
Find all documents where the tripduration was less than or equal to 70 seconds and the usertype was Customer using a redundant equality operator: ```javascript db.trips.find({ "tripduration": { "$lte" : 70 }, "usertype": { "$eq": "Customer" }}).pretty() ```
Find all documents where the tripduration was less than or equal to 70 seconds and the usertype was Customer using the implicit equality operator: ```javascript db.trips.find({ "tripduration": { "$lte" : 70 }, "usertype": "Customer" }).pretty() ```

Keywords:



Sources:

  1. university.mongodb.com