MongoDB Basics: Chapter 4: Advanced CRUD Operations - Array Operators and Sub-Documents


No Action
1
MongoDB Basics: Chapter 4: Advanced CRUD Operations - Array Operators and Sub-Documents

0 comment

21 December 2020, 10:05 am by antelove19

MongoDB Basics: Chapter 4: Advanced CRUD Operations - Array Operators and Sub-Documents
MongoDB Basics: Chapter 4: Advanced CRUD Operations - Array Operators and Sub-Documents

Commands used in this lesson: Connect to the Atlas cluster: ```javascript mongo "mongodb+srv://:@.mongodb.net/admin" ``` ```javascript use sample_training db.trips.findOne({ "start station location.type": "Point" }) db.companies.find({ "relationships.0.person.last_name": "Zuckerberg" }, { "name": 1 }).pretty() db.companies.find({ "relationships.0.person.first_name": "Mark", "relationships.0.title": { "$regex": "CEO" } }, { "name": 1 }).count() db.companies.find({ "relationships.0.person.first_name": "Mark", "relationships.0.title": {"$regex": "CEO" } }, { "name": 1 }).pretty() db.companies.find({ "relationships": { "$elemMatch": { "is_past": true, "person.first_name": "Mark" } } }, { "name": 1 }).pretty() db.companies.find({ "relationships": { "$elemMatch": { "is_past": true, "person.first_name": "Mark" } } }, { "name": 1 }).count() ```

Keywords:



Sources:

  1. university.mongodb.com