https://github.com/nilooy/nilz-change-stream
To use mongo change stream server to publish meteor data
https://github.com/nilooy/nilz-change-stream
change-stre meteor meteor-change-stream meteor-performance mongodb
Last synced: 3 months ago
JSON representation
To use mongo change stream server to publish meteor data
- Host: GitHub
- URL: https://github.com/nilooy/nilz-change-stream
- Owner: nilooy
- License: mit
- Created: 2021-06-26T21:09:29.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-27T20:47:26.000Z (almost 4 years ago)
- Last Synced: 2025-01-27T07:08:40.015Z (4 months ago)
- Topics: change-stre, meteor, meteor-change-stream, meteor-performance, mongodb
- Language: JavaScript
- Homepage: https://atmospherejs.com/nilz/change-stream
- Size: 17.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: change-stream-tests.js
- License: LICENSE
Awesome Lists containing this project
README
# Meteor Change Stream | nilz:change-stream
[](https://www.repostatus.org/#active)
#### To use mongo change stream server to publish meteor data
> #### Install instruction
```shell script
meteor add nilz:change-stream
```> #### Usage instruction
```js
// simple usage to publish data with change stream without any query
// same as `SomeCollection.find() in meteor publish`
Meteor.publishChangeStream({
name: 'get1',
collection: House
})
```
For querying the data, here aggregation framework have been used
> For more details https://docs.mongodb.com/manual/changeStreams/#modify-change-stream-output
```js
// simple usage to publish data with change stream
Meteor.publishChangeStream({
name: 'get1',
collection: House,
pipleline: [ // aggregation pipeline
{ $match: { 'fullDocument.username': 'alice' } }
]
})
```# !important: add `fullDocument` before each fields in pipeline as example above
### Support only transformation, so no `$lookup` for now :(
```javascript
$addFields
$match
$project
$replaceRoot
$replaceWith (Available starting in MongoDB 4.2)
$redact
$set (Available starting in MongoDB 4.2)
$unset (Available starting in MongoDB 4.2)
```> ### Reason: (https://docs.mongodb.com/manual/changeStreams/)
Change streams allow applications to access real-time data changes without the complexity and risk of tailing the oplog.
Applications can use change streams to subscribe to all data changes on a single collection, a database, or an entire deployment, and immediately react to them. Because change streams use the aggregation framework, applications can also filter for specific changes or transform the notifications at will.> ### Need to implement:
- Resume a Change Stream | https://docs.mongodb.com/manual/changeStreams/#resume-a-change-stream
- Add tests.
- Option to rerun query on change stream event trigger. Might be able to implement rerun with proper aggregation pipeline> ### Guides:
- https://severalnines.com/database-blog/real-time-data-streaming-mongodb-change-streams
- https://docs.mongodb.com/manual/changeStreams/#change-streams
- https://developer.mongodb.com/quickstart/nodejs-change-streams-triggers