Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mistakster/rxjs-mongodb

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mistakster/rxjs-mongodb

A helper which creates an Observable from MongoDB connection

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

rxjs-mongodb

It's the proper way to get a MongoDB Client as an Observable.

Motivation

It’s quite tricky to convert a connection to a MongoDB server to an Observable. A stream should meet the following requirements:

  1. It must emit an event with the instance only once.
  2. It must emit any errors.
  3. It must wait until the disconnection.

Also, the client must disconnect from the server if no subscription currently exists.

Usage


const client$ = connectMongoDb(MONGODB_URL, MONGODB_OPTS);

const data$ = client$.pipe(
  map(client => client.db(MONGODB_DATABASE)),
  map(db => db.collection('items')),
  map(items => items.find({ value: { $gte: 0.5 } })),
  map(cursor => cursor.transformStream()),
  mergeMap(streamToRx)
);

data$.subscribe(datum => {
  console.log(datum._id);
});

License

MIT

Keywords

FAQs

Package last updated on 16 Aug 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc