Challenge - 5 Problems
BSON Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of this BSON document query?
Given a MongoDB collection with documents containing a field
Note:
value of type Int32, what will be the output of this query?db.collection.find({ value: { $type: 16 } })Note:
$type: 16 filters documents where value is of BSON type Int32.MongoDB
db.collection.find({ value: { $type: 16 } })Attempts:
2 left
💡 Hint
Check the BSON type number for Int32 in MongoDB documentation.
✗ Incorrect
In MongoDB, BSON type 16 corresponds to Int32. The query filters documents where 'value' is exactly a 32-bit integer.
🧠 Conceptual
intermediate1:30remaining
Which BSON data type is used to store date and time?
In BSON, which data type is used to store date and time values?
Attempts:
2 left
💡 Hint
Think about the type that stores calendar dates and times.
✗ Incorrect
The BSON 'Date' type stores date and time as milliseconds since the Unix epoch.
📝 Syntax
advanced1:30remaining
Identify the BSON type code for a 64-bit integer
Which BSON type number corresponds to a 64-bit integer (Int64) in MongoDB?
Attempts:
2 left
💡 Hint
Int32 is 16, double is 1, string is 2.
✗ Incorrect
BSON type 18 represents Int64 (64-bit integer).
🔧 Debug
advanced2:00remaining
Why does this query return no results?
A user runs this query to find documents with a field
But no documents are returned, even though some documents have
score of type double:db.collection.find({ score: { $type: 1 } })But no documents are returned, even though some documents have
score as a floating-point number. What is the most likely reason?Attempts:
2 left
💡 Hint
Check the actual BSON type of the
score field in documents.✗ Incorrect
If
score is stored as a string, filtering by $type:1 (double) returns no matches.❓ optimization
expert2:30remaining
Optimizing queries filtering by BSON type
You want to optimize a MongoDB query that filters documents by the BSON type of a field
data. Which approach is the most efficient for large collections?Attempts:
2 left
💡 Hint
Indexes help queries run faster when used properly.
✗ Incorrect
Using $type with an index on the field allows MongoDB to efficiently filter documents by BSON type.