Complete the code to start a change stream that listens for all changes.
const changeStream = collection.watch([1]);The watch method takes an array as the pipeline argument. An empty array [] means no filtering, so all changes are listened to.
Complete the code to filter change events to only include inserts.
const pipeline = [ { $match: { operationType: [1] } } ];The operationType field indicates the type of change. To filter for inserts, use 'insert'.
Fix the error in the pipeline to filter changes where the field 'status' is 'active'.
const pipeline = [ { $match: { 'fullDocument.status': [1] } } ];String values in MongoDB queries must be quoted. So 'active' is correct.
Fill both blanks to filter change events for updates where the 'age' field is greater than 30.
const pipeline = [ { $match: { operationType: [1], 'fullDocument.age': { [2]: 30 } } } ];To filter for update events, use 'update'. To check if 'age' is greater than 30, use the MongoDB operator $gt.
Fill all three blanks to create a pipeline that filters for delete operations where the document's 'score' is less than 50.
const pipeline = [ { $match: { operationType: [1], 'fullDocument.score': { [2]: 50 }, 'ns.db': [3] } } ];To filter delete operations, use 'delete'. To check if 'score' is less than 50, use $lt. The database name is a string, so use 'myDatabase'.