Complete the code to start a change stream with a resume token.
const changeStream = collection.watch([], { resumeAfter: [1] });The resumeAfter option uses the resume token to continue watching changes from where it left off.
Complete the code to retrieve the resume token from a change stream event.
const resumeToken = changeEvent[1];The resume token is stored in the _id field of the change event.
Fix the error in the code to resume a change stream after a disconnect.
const changeStream = collection.watch([], { [1]: lastResumeToken });To resume a change stream after a disconnect, use the resumeAfter option with the last resume token.
Fill both blanks to create a change stream that resumes after a token and returns full documents.
const changeStream = collection.watch([], { [1]: resumeToken, [2]: 'updateLookup' });The resumeAfter option resumes the stream after the given token, and fullDocument: 'updateLookup' returns the full updated document on change.
Fill all three blanks to store the resume token from a change event and resume the stream correctly.
changeStream.on('change', (changeEvent) => { const [1] = changeEvent.[2]; // Later resume with const resumedStream = collection.watch([], { [3]: [1] }); });
We store the resume token from changeEvent._id in lastResumeToken. Then we resume the stream using resumeAfter: lastResumeToken.