0
0
MongoDBquery~10 mins

Insert with nested documents in MongoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to insert a document with a nested address field.

MongoDB
db.users.insertOne({ name: "Alice", address: [1] })
Drag options to blanks, or click blank then click option'
Acity: "New York", zip: "10001"
B"city: New York, zip: 10001"
C{ city: "New York", zip: "10001" }
D[ city: "New York", zip: "10001" ]
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets instead of curly braces for nested documents.
Writing nested fields as a string instead of an object.
2fill in blank
medium

Complete the code to insert a user with nested contact details.

MongoDB
db.users.insertOne({ name: "Bob", contact: [1] })
Drag options to blanks, or click blank then click option'
A{ phone: "123-4567", email: "bob@example.com" }
B[ phone: "123-4567", email: "bob@example.com" ]
C"phone: 123-4567, email: bob@example.com"
Dphone: "123-4567", email: "bob@example.com"
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets instead of curly braces.
Writing nested fields as a string.
3fill in blank
hard

Fix the error in the insertOne command to correctly insert nested documents.

MongoDB
db.orders.insertOne({ orderId: 101, details: [1] })
Drag options to blanks, or click blank then click option'
A{ product: "Book", quantity: 2 }
B"product: Book, quantity: 2"
C[ product: "Book", quantity: 2 ]
Dproduct: "Book", quantity: 2
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets for nested documents.
Writing nested fields as a string.
4fill in blank
hard

Fill both blanks to insert a product with nested specifications and dimensions.

MongoDB
db.products.insertOne({ name: "Laptop", specs: [1], dimensions: [2] })
Drag options to blanks, or click blank then click option'
A{ cpu: "Intel i7", ram: "16GB" }
B[ cpu: "Intel i7", ram: "16GB" ]
C{ width: 13, height: 9, depth: 0.6 }
D[ width: 13, height: 9, depth: 0.6 ]
Attempts:
3 left
💡 Hint
Common Mistakes
Using arrays instead of objects for nested documents.
Mixing curly braces and square brackets incorrectly.
5fill in blank
hard

Fill all three blanks to insert a blog post with nested author, tags, and metadata fields.

MongoDB
db.posts.insertOne({ title: "MongoDB Tips", author: [1], tags: [2], metadata: [3] })
Drag options to blanks, or click blank then click option'
A{ name: "Jane", email: "jane@example.com" }
B[ "database", "nosql", "mongodb" ]
C{ views: 150, likes: 10 }
D"database, nosql, mongodb"
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings instead of arrays for tags.
Using arrays instead of objects for author or metadata.