MongoDB instances are required to have a Replica Set enable to allow Change Streams invocation. A quick tutorial to enable this can be found here.
const { MongoClient } = require("mongodb");
const versionr = require('mongodb-versionr');
const uri = "<your_mongo_client_uri>";
const client = new MongoClient(uri);
vnrContext = versionr.setContext(client);
vnrContext.registerModel({
collection_name: "<your_collection>",
database_name: "<your_database>",
version_control_database_name: "<your_versioning_collection>",
version_control_collection_name: "<your_versioning_collection>",
keys: {
"key1": "value1"
...
}
});
If version_control_database_name
is not provided, then database_name
is set as the version control database.
vnrContext.stopListeners();