Demostration of pushing MongoDB realtime changes to browser and reactively rendering them. It is using the old opstream approach (it is now superseded by https://docs.mongodb.com/manual/changeStreams/).
git clone kristjanjansen/mongostream
cd mongostream
npm i # or yarn
npm run build
You will need to configure Mongo to use replicasets / oplog in order to get the realtime changefeed.
Assuming you are installed MongoDB on OSX using brew install
:
mongod --config /usr/local/etc/mongod.conf --replSet rs
Note: You can likely skip
--config
setting when in other platforms
Then log into Mongo shell
mongo localhost:27017/test
and run
rs.initiate({ _id: "rs", members: [ {_id: 0, host: "localhost:27017"} ] })
For mLab you will need a paid plan http://docs.mlab.com/oplog/
MongoDb Atlas information: https://docs.atlas.mongodb.com/faq/#does-mongodb-service-expose-the-oplog
node index
and point the browser to http://localhost:8080
Insert
node insert mykey value
Update
node update mykey value newvalue