From ae6d82f5e9465d6a96b72c9e3473cd124d97384f Mon Sep 17 00:00:00 2001 From: zeus Date: Tue, 24 Nov 2020 19:19:22 +0200 Subject: [PATCH] mongo tail --- swarmlab-app/src/run/app.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/swarmlab-app/src/run/app.js b/swarmlab-app/src/run/app.js index c8c5852..16dd6e5 100755 --- a/swarmlab-app/src/run/app.js +++ b/swarmlab-app/src/run/app.js @@ -410,7 +410,17 @@ MongoClient.connect(mongourl, OPTS, function(err, client){ console.log(err); } else { const db = client.db('fluent'); - db.collection('log', onCollection); + //db.collection('log', onCollection); + var stream = db.log.find({}, { + tailable: true, + awaitdata: true + /* other options */ +}).stream(); + +stream.on('data', function (doc) { + console.log(JSON.stringify(doc)) + //socket.write(JSON.stringify({'action': 'log','param': doc.log})); +}); /* db.collection(function(err, collections) { collections.forEach(function(coll) {