|
@ -317,18 +317,44 @@ if(RES.error == 'ok'){ |
|
|
const db = client.db('fluent'); |
|
|
const db = client.db('fluent'); |
|
|
//db.collection('log', onCollection);
|
|
|
//db.collection('log', onCollection);
|
|
|
console.log(JSON.stringify('mongo connected')) |
|
|
console.log(JSON.stringify('mongo connected')) |
|
|
var stream = db.collection('logs').find({}, { |
|
|
|
|
|
tailable: true, |
|
|
|
|
|
awaitdata: true |
|
|
|
|
|
}).stream(); |
|
|
|
|
|
|
|
|
|
|
|
stream.on('data', function (doc) { |
|
|
db.collection('logs').find({}, {}) |
|
|
console.log(JSON.stringify(doc)) |
|
|
.then(item => { |
|
|
//socket.write(JSON.stringify({'action': 'log','param': doc.log}));
|
|
|
console.log(item) |
|
|
RES.error_msg = "ok" |
|
|
RES.error_msg = "ok" |
|
|
RES.data = doc |
|
|
RES.data = item |
|
|
res.json(RES) |
|
|
res.json(RES) |
|
|
}); |
|
|
}) |
|
|
|
|
|
.catch(err => { |
|
|
|
|
|
console.error(err) |
|
|
|
|
|
RES.error_msg = err |
|
|
|
|
|
RES.data = stream |
|
|
|
|
|
res.json(RES) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const find = async () => { |
|
|
|
|
|
try { |
|
|
|
|
|
var stream = await db.collection('logs').find({}, {}) |
|
|
|
|
|
RES.error_msg = "ok" |
|
|
|
|
|
RES.data = stream |
|
|
|
|
|
res.json(RES) |
|
|
|
|
|
} catch(err => { |
|
|
|
|
|
RES.error_msg = err |
|
|
|
|
|
RES.data = stream |
|
|
|
|
|
res.json(RES) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await find() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//stream.on('data', function (doc) {
|
|
|
|
|
|
// console.log(JSON.stringify(doc))
|
|
|
|
|
|
//socket.write(JSON.stringify({'action': 'log','param': doc.log}));
|
|
|
|
|
|
//});
|
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}else{ |
|
|
}else{ |
|
|