Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gkampitakis/mongodb-change-streams
Testing change streams feature in mongodb
https://github.com/gkampitakis/mongodb-change-streams
change-streams docker-compose fastify mongodb nodejs
Last synced: about 1 month ago
JSON representation
Testing change streams feature in mongodb
- Host: GitHub
- URL: https://github.com/gkampitakis/mongodb-change-streams
- Owner: gkampitakis
- License: mit
- Created: 2020-10-28T21:34:42.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-22T13:34:02.000Z (over 2 years ago)
- Last Synced: 2023-03-06T06:37:13.267Z (almost 2 years ago)
- Topics: change-streams, docker-compose, fastify, mongodb, nodejs
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Mongodb Change Streams
## Table of contents
- [Description](#Description)
- [Prerequisites](#Prerequisites)
- [Usage](#Usage)
- [Resources](#Resources)## Description
Change Streams give the ability to applications monitor data-changes and react to this changes on a single collection, a database or an entire deployment.
## Prerequisites
If you want to run the code in this repository you will need to spin up `fastify server` that produces new data changes in mongodb, a listener service that listen to data changes and of course you' ll need a mongodb in [replica set or shared clusters](https://docs.mongodb.com/manual/changeStreams/#availability).
I have provide a `docker-compose.yml` file in order to run locally mongodb in replica set. [For information on how to set it](https://gist.github.com/asoorm/7822cc742831639c93affd734e97ce4f).
## Usage
- Install dependencies by running `npm i`.
- Start ***fastify-server*** with `npm run start:server`
- Start on another cmd the ***listener*** with `npm run start:listener`I have provided a postman collection that you can use to do requests to
***fastify-server*** or you can just use `curl` command.```bash
# Insert Event
curl -X POST -H "Content-Type: application/json" \
-d '{"message": "Hello World"}' \
http://localhost:5000/notification# Update Event
curl -X PUT -H "Content-Type: application/json" \
-d '{"message": "test"}' \
http://localhost:5000/notification/# Delete Event
curl -X DELETE \
http://localhost:5000/notification/
```## Resources
For more information you can start
- [From official docs about changeStreams](https://docs.mongodb.com/manual/changeStreams/)
- [An introduction to change streams](https://www.mongodb.com/blog/post/an-introduction-to-change-streams)
- [Change Events](https://docs.mongodb.com/manual/reference/change-events)