Skip to content

gkampitakis/mongodb-change-streams

Repository files navigation

Mongodb Change Streams

Table of contents

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.

I have provide a docker-compose.yml file in order to run locally mongodb in replica set. For information on how to set it.

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.

# 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/<id>

# Delete Event
curl -X DELETE \
    http://localhost:5000/notification/<id>

Resources

For more information you can start

✌️ For any questions or issues ✌️

Releases

No releases published

Packages

No packages published