0
0
MongoDBquery~10 mins

Resume tokens for reliability 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 start a change stream with a resume token.

MongoDB
const changeStream = collection.watch([], { resumeAfter: [1] });
Drag options to blanks, or click blank then click option'
AresumeToken
BbatchSize
CfullDocument
DstartAtOperationTime
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'startAtOperationTime' instead of 'resumeAfter' for resuming.
Passing the full document instead of the resume token.
Confusing batch size with resume token.
2fill in blank
medium

Complete the code to retrieve the resume token from a change stream event.

MongoDB
const resumeToken = changeEvent[1];
Drag options to blanks, or click blank then click option'
A_id
Btoken
CresumeToken
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to access a non-existent 'resumeToken' field.
Using 'id' instead of '_id'.
Using 'token' which is not a valid field.
3fill in blank
hard

Fix the error in the code to resume a change stream after a disconnect.

MongoDB
const changeStream = collection.watch([], { [1]: lastResumeToken });
Drag options to blanks, or click blank then click option'
AstartAfter
BresumeAfter
CstartAtOperationTime
DfullDocument
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'startAfter' which is not a valid option.
Using 'startAtOperationTime' which resumes differently.
Confusing 'fullDocument' option with resume token.
4fill in blank
hard

Fill both blanks to create a change stream that resumes after a token and returns full documents.

MongoDB
const changeStream = collection.watch([], { [1]: resumeToken, [2]: 'updateLookup' });
Drag options to blanks, or click blank then click option'
AresumeAfter
BstartAtOperationTime
CfullDocument
DbatchSize
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up 'startAtOperationTime' with 'resumeAfter'.
Using 'batchSize' instead of 'fullDocument'.
Not setting 'fullDocument' to 'updateLookup' when needed.
5fill in blank
hard

Fill all three blanks to store the resume token from a change event and resume the stream correctly.

MongoDB
changeStream.on('change', (changeEvent) => {
  const [1] = changeEvent.[2];
  // Later resume with
  const resumedStream = collection.watch([], { [3]: [1] });
});
Drag options to blanks, or click blank then click option'
AlastResumeToken
B_id
CresumeAfter
DfullDocument
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names for the token.
Accessing a wrong field instead of '_id'.
Using 'fullDocument' instead of 'resumeAfter' to resume.