An open API service indexing awesome lists of open source software.

https://github.com/goliatone/mongodb-change-streams-listeners

MongoDB Change Streams Listeners
https://github.com/goliatone/mongodb-change-streams-listeners

Last synced: 2 months ago
JSON representation

MongoDB Change Streams Listeners

Awesome Lists containing this project

README

        

## MongoDB Change Streams Listeners

Manage listeners for MongoDB change streams.

```js
const watcher = new Watcher({
connection: {
uri: process.env.NODE_MONGOURL,
},
options: {
storage: {
batchSize: 10
}
},
listeners: [{
collection: 'profiles',
when: [Watcher.UPDATE],
filter: { email: '[email protected]' },
fields: ['profilePicture', 'presence'],
data: {
topic: 'profiles.goliatone'
}
}]
});

watcher.on('profile.update', changeset => {
if (changeset.change.operationType === 'update') {
console.log('presence: %s', Keypath.get(changeset.change, 'updatedFields.presence'));
}
});

watcher.start();
```