Socket
Book a DemoInstallSign in
Socket

real-time-observer

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

real-time-observer

![RealTimeObserver](https://github.com/kingsae1/real-time-observer/blob/main/realtimeobserver.JPG?raw=true)

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

RealTimeObserver

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

FAQs

Package last updated on 25 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts