0
0
MongoDBquery~10 mins

$mul operator for multiplication 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 multiply the field 'price' by 2 in the update operation.

MongoDB
db.products.updateOne({ _id: 1 }, { $mul: { price: [1] } })
Drag options to blanks, or click blank then click option'
A2
Bprice
C1
D$price
Attempts:
3 left
💡 Hint
Common Mistakes
Using the field name instead of a number as multiplier.
Including a dollar sign before the multiplier number.
2fill in blank
medium

Complete the code to multiply the 'quantity' field by 5 for all documents matching the filter.

MongoDB
db.inventory.updateMany({ category: 'books' }, { $mul: { quantity: [1] } })
Drag options to blanks, or click blank then click option'
A5
Bcategory
C'5'
D$quantity
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string '5' instead of number 5.
Using the field name or a dollar sign before the multiplier.
3fill in blank
hard

Fix the error in the update command to multiply 'score' by 3.

MongoDB
db.scores.updateOne({ user: 'alice' }, { $mul: { score: [1] } })
Drag options to blanks, or click blank then click option'
Ascore
B3
C$3
D'3'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string '3' instead of number 3.
Using the field name or dollar sign as multiplier.
4fill in blank
hard

Fill both blanks to multiply 'price' by 1.5 and 'stock' by 10 in a single update.

MongoDB
db.store.updateOne({ _id: 10 }, { $mul: { price: [1], stock: [2] } })
Drag options to blanks, or click blank then click option'
A1.5
B10
C'10'
D'1.5'
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings instead of numbers for multipliers.
Mixing up the values for 'price' and 'stock'.
5fill in blank
hard

Fill all three blanks to multiply 'rating' by 2, 'views' by 100, and 'likes' by 5 in one update.

MongoDB
db.analytics.updateMany({ active: true }, { $mul: { rating: [1], views: [2], likes: [3] } })
Drag options to blanks, or click blank then click option'
A2
B100
C5
D'5'
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings instead of numbers for multipliers.
Using dollar signs or field names instead of numbers.