mongo-changestream-connector v1.3.1
Mongo Changestream Connector
Description
Connect and change streams with Mongoose
This module is created for Mongo Live Server
How to install
This module depends on mongodb. If you're using Mongoose, and you want to create Mongoose connections instead of native MongoDB connections, e.g. to instantiate your Mongoose models with, mongoose@5 is a peer dependency of this module. So, make sure that Mongoose version 5 is installed in your project.
npm i mongo-changestream-connectorOr when using yarn:
yarn add mongo-changestream-connectorHow to use
Supply the setting useMongoose: true to the Connector constructor.
Now, after using the mongoose connection to instantiate models, you can access all mongoose models with Connector.models. The reference to the native MongoDB with Connector.db will now not be available anymore.
Finally, instead of specifying collectionName in the changeStream method, specify modelName.
Convenience variables:
When using Mongoose
connector.models
When using MongoDB
MongoClient connector.mongoClient = client
Db Instance the return value of mongoClient.db()
connector.db
How to contribute
Release
- Run
npm run release-testto make sure that everything is ready and correct for publication on NPM. - If the previous step succeeded, release a new master version with a raised version tag following the git flow standard.
- Run
npm run releaseto finally publish the module on NPM.
How to test
Run all the tests once with coverage:
npm testRun all the tests without coverage and with a watch:
npm testsRun the MongoDB tests without coverage and with a watch:
npm test-mongoRun the Mongoose tests without coverage and with a watch:
npm test-mongoose