Browse Source

mongo tail

master
zeus 4 years ago
parent
commit
ae6d82f5e9
  1. 12
      swarmlab-app/src/run/app.js

12
swarmlab-app/src/run/app.js

@ -410,7 +410,17 @@ MongoClient.connect(mongourl, OPTS, function(err, client){
console.log(err); console.log(err);
} else { } else {
const db = client.db('fluent'); 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) { db.collection(function(err, collections) {
collections.forEach(function(coll) { collections.forEach(function(coll) {

Loading…
Cancel
Save