Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The nested document must be an object with key-value pairs inside curly braces.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets instead of curly braces.
Writing nested fields as a string.
✗ Incorrect
Nested documents must be objects with key-value pairs inside curly braces.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets for nested documents.
Writing nested fields as a string.
✗ Incorrect
Nested documents must be objects inside curly braces, not arrays or strings.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using arrays instead of objects for nested documents.
Mixing curly braces and square brackets incorrectly.
✗ Incorrect
Both specs and dimensions are nested documents and must be objects inside curly braces.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings instead of arrays for tags.
Using arrays instead of objects for author or metadata.
✗ Incorrect
Author and metadata are nested documents (objects), tags is an array of strings.