0
0
MongoDBquery~10 mins

BSON data types overview 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 string field in MongoDB.

MongoDB
db.collection.insertOne({ name: [1] })
Drag options to blanks, or click blank then click option'
Anull
B123
C"Alice"
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around string values.
Using numbers or booleans instead of strings.
2fill in blank
medium

Complete the code to insert a document with a boolean field in MongoDB.

MongoDB
db.collection.insertOne({ active: [1] })
Drag options to blanks, or click blank then click option'
A"true"
Btrue
C"false"
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around boolean values.
Using capitalized False instead of lowercase false.
3fill in blank
hard

Fix the error in the code to insert a document with a date field in MongoDB.

MongoDB
db.collection.insertOne({ createdAt: [1] })
Drag options to blanks, or click blank then click option'
Anew Date()
B"new Date()"
CDate()
Ddate()
Attempts:
3 left
💡 Hint
Common Mistakes
Putting new Date() inside quotes, making it a string.
Using Date() without new, which returns a string.
4fill in blank
hard

Fill both blanks to create a document with an ObjectId and a null field.

MongoDB
db.collection.insertOne({ _id: [1], deletedAt: [2] })
Drag options to blanks, or click blank then click option'
AObjectId()
Bnull
Cundefined
Dnew ObjectId()
Attempts:
3 left
💡 Hint
Common Mistakes
Using undefined instead of null.
Using new ObjectId() which is valid but not the preferred shorthand here.
5fill in blank
hard

Fill all three blanks to create a document with a binary data field, a decimal number, and an array.

MongoDB
db.collection.insertOne({ data: [1], price: [2], tags: [3] })
Drag options to blanks, or click blank then click option'
ABinData(0, "AQID")
BDecimal128("19.99")
C["sale", "new"]
DBuffer.from("AQID")
Attempts:
3 left
💡 Hint
Common Mistakes
Using Buffer.from which is Node.js specific, not BSON.
Using strings instead of arrays for tags.