1.0.3 • Published 3 years ago
real-time-observer v1.0.3
Author : kingsae1004@gmail.com
What is RealTimeObserver?
real-time-observer is a plugin of node module to subscribe lots of databases. but this beta feature is available to use MongoDB
How to use?
At first, Must initailize Observer class with config (currently support only for MongoDB)
const { RTMongoObserver } = require("./index.js");
const observer = new RTMongoObserver({
SERVER_TYPE: "MONGODB",
SERVER_URL: "",
SERVER_ID: "",
SERVER_PW: "",
MONGO_DATABASE: "",
MONGO_COLLECTION: "",
});
And then optionally you can define collection name. If not defined, load the config property (MONGO_COLLECTION)
observer.getCollection("COLLECTION_NAME");
This way is to subscribe observer (MongoDB collection)
// subscribe database
observer.subscribe(observer.getCollection()).then((data) => {
console.log(data);
});
I recommend unsubscribe after (unmount/disolve/disable ..) case
// Remove Listner
setTimeout(() => {
observer.unsubscribe(observer.getCollection());
}, 2000);
How to use test?
npm run test