Added MongoDbChangeStream option.

This commit is contained in:
Ylian Saint-Hilaire
2019-05-28 17:42:11 -07:00
parent 0e7c091530
commit 88b0b8601c
3 changed files with 8 additions and 7 deletions

6
db.js
View File

@@ -230,8 +230,8 @@ module.exports.CreateDB = function (parent, func) {
});
// Setup the changeStream on the MongoDB main collection if possible
try {
obj.fileChangeStream = obj.file.watch([{ $match: { 'fullDocument.type': { $in: [ 'node', 'mesh', 'user' ] } } }], { fullDocument: 'updateLookup' });
if (parent.args.mongodbchangestream == true) {
obj.fileChangeStream = obj.file.watch([{ $match: { 'fullDocument.type': { $in: ['node', 'mesh', 'user'] } } }], { fullDocument: 'updateLookup' });
obj.fileChangeStream.on('change', function (change) {
switch (change.fullDocument.type) {
case 'node': { dbNodeChange(change); break; } // A node has changed
@@ -240,7 +240,7 @@ module.exports.CreateDB = function (parent, func) {
}
});
obj.changeStream = true;
} catch (ex) { }
}
// Setup MongoDB events collection and indexes
obj.eventsfile = db.collection('events'); // Collection containing all events