-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
Affects Version/s: 3.0.6
-
Component/s: Native
-
Environment:MongoDb v3.4.13, Node.js v6.13.0, Node.js MongoDB Driver 3.0.6
-
Empty show more show less
Not sure of the proper way to pipe query results using MongoDB Node.js Drive 3.0. According to the docs, `Cursor::pipe` and `AggregateCursor::pipe` receive a Writeable streams so it seems like you should be able to do something like this:
collection.find(query).pipe(process.stdout);
collection.aggregate(query).pipe(process.stdout);
But it turns out to throw an error:
TypeError: Invalid data, chunk must be a string or buffer, not object
This works but it feels a little cumbersome to me doesn't lend itself to pipe chaining.
collection.find(query)
.on('data', function(chunk)
collection.aggregate(query)
.on('data', function(chunk) { buffer = Buffer.from(JSON.stringify(chunk)) process.stdout.write( buffer ); }
);
Is there a way to do a standard pipe chain with with the MongoDB Driver for Node.js?
- is documented by
-
NODE-1410 Improve Cursor Documentation in native
- Closed