0
0
MongoDBquery~20 mins

Change stream events (insert, update, delete) in MongoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Change Stream Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
1:30remaining
Identify the change stream event type for a document insertion
Given a MongoDB change stream watching a collection, what is the value of the operationType field in the event document when a new document is inserted?
A"update"
B"delete"
C"insert"
D"replace"
Attempts:
2 left
💡 Hint
Think about what the event type would be when a new document is added.
query_result
intermediate
1:30remaining
Determine the change stream event for a document deletion
What is the operationType value in a MongoDB change stream event when a document is deleted from a collection?
A"delete"
B"drop"
C"insert"
D"update"
Attempts:
2 left
💡 Hint
Consider the event type that signals removal of a document.
📝 Syntax
advanced
2:00remaining
Which change stream event document contains the updated fields?
In a MongoDB change stream event for an update operation, which field contains the changed fields and their new values?
A"documentKey"
B"updateDescription.updatedFields"
C"fullDocument"
D"ns"
Attempts:
2 left
💡 Hint
Look for the field that describes what changed inside the document.
🧠 Conceptual
advanced
2:00remaining
Understanding the difference between 'replace' and 'update' events
Which statement correctly describes the difference between a 'replace' and an 'update' operationType in MongoDB change streams?
A'replace' means the entire document was replaced; 'update' means only some fields changed
B'replace' means the document was deleted; 'update' means the document was inserted
C'replace' and 'update' are synonyms and mean the same thing
D'replace' means the collection was dropped; 'update' means the document was replaced
Attempts:
2 left
💡 Hint
Think about whether the whole document or just parts of it changed.
🔧 Debug
expert
2:30remaining
Identify the error in this change stream pipeline
You want to watch only delete events on a collection using a change stream with this pipeline:
[ { $match: { operationType: "delete" } } ]
But your code throws an error. What is the most likely cause?
MongoDB
const pipeline = [ { $match: { operationType: "delete" } } ];
const changeStream = collection.watch(pipeline);
AThe 'operationType' field should be matched as a number, not a string
BThe pipeline must use '$match' with 'fullDocument' instead of 'operationType'
CThe 'operationType' field must be inside 'updateDescription' in the match stage
DThe pipeline is correct; the error is likely from missing permissions or connection issues
Attempts:
2 left
💡 Hint
Check if the pipeline syntax matches MongoDB documentation for filtering by operationType.