Support: Get raw data (JSON) from Cursor instead of JS objects

8 views
Skip to first unread message

Alexander Mills

unread,
Mar 16, 2018, 3:29:07 PM3/16/18
to node-mongodb-native
I have this code which gets a Cursor from a query:

MongoClient.connect(uri).then(function (client) {
const db = client.db('local');
const coll = db.collection('oplog.rs');

   const q = coll.find(query, {
     tailable: true,
awaitData: true,
oplogReplay: true,
noCursorTimeout: true,
numberOfRetries: Number.MAX_VALUE
});

const changeStream = q.stream(); ///// the stream !

});



that q.stream() call should return one of these:

export class Cursor<T = Default> extends Readable {}


MY QUESTION IS:
that stream seems to send Objects to event handlers.
Is there a way to get raw string data, like JSON instead of JS objects?

Perhaps there is another option I can pass to the coll.find options?
e.g. {raw:true}
Reply all
Reply to author
Forward
0 new messages