observable-mongo
v2.3.17
Published
Functions that provide 'node mongodb driver APIs' as Observables
Downloads
113
Maintainers
Readme
observable-mongo
Functions that provide some 'node mongodb driver APIs' as Observables.
To run the tests it is required to have a working instance of Mongo to connect to. The default is to have a local mongo installed at port 27017 as specified in the default "config.ts" file in the "src" folder.
In case you want to run the tests on other mongo instances, change "config.ts" and run the command "npm run tsc" to rigenerate the "dist" directory with the configuration information
examples
For use cases that see different asyncrhonous elements interacting, using the Observable pattern can simplify and clarify the code.
A simple use case can be the following:
- you need to read from a Mongo collection a list of authors
- for each author you need to query a REST API to fetch the titles on the author
- than you need to write the titles in a file with the author name
In this case you need to interact with Mongo, http requests and the Node fs library, which all offer asynchrnous APIs. If these APIs offer also an Observable version, that the code of the example can be written as a single stream, leading to a more readable code (personal opinion).
The example in the repo represents this use case using observable-http-request and observable-fs, which are companion libraries of observable-mongo.