Grokking MongoDB
Vote

0% completed

​

Adding Elements to Arrays

Bob has two new scores, 75 and 88, and they need to go into his scores array. The obvious update stores them in the wrong form, and it raises no error.

db.users.drop() db.users.insertMany([ { name: "Alice", hobbies: ["reading", "traveling"], scores: [85, 90, 88] }, { name: "Bob", hobbies: ["cycling", "hiking"], scores: [78, 82, 79] }, { name: "Charlie", hobbies: ["gaming", "reading"], scores: [92, 85, 90] }, { name: "David", hobbies: ["swimming", "biking"], scores: [88, 84, 89] }, { name: "Eve", hobbies: ["running", "painting"], scores: [80, 86, 81] } ])

``

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content