Hello, I need to make hooks for every insert, update and remove
I found 2 ways right now:
-
GitHub - Meteor-Community-Packages/meteor-collection-hooks: Meteor Collection Hooks
-
Collections and Schemas | Meteor Guide
but when I see the version latest update, it already 2 years ago
hmm
which one is better?
or is there the better and newest way?
btw I using typescript
wish it also support typescript
thanks
There is another option: use mongodb change stream, but it works only with replica set.
Meteor.startup(() => {
const changeStream = SomeCollection.rawCollection().watch([
{ $match: { operationType: 'insert' } },
])
console.log(changeStream)
changeStream.on('change', (next) => {
console.log(next)
})
})