.cursor({ transform: JSON.stringify }) doesn't work the same way for AggregationCursor as in QueryCursor (when piped to response) #14331
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Prerequisites
Mongoose version
8.1.1
Node.js version
18.13.0
MongoDB server version
6.0.4
Typescript version (if applicable)
5.3.3
Description
The { transform: JSON.stringify } option for a cursor doesn't produce the expected result on aggregation cursors while they work fine with query cursors.
The example below with .find() works well and you can get the streamed documents on the client
Whereas the same request (below) with aggregation/$match doesn't work and you get an error like the one at the bottom:
Steps to Reproduce
Replacing a find query with $match aggregation on a cursor response can demonstrate the issue.
Note that the aggregation cursor works well. ie if you do simply read the cursor with .next(), you can get the values fine. The issue happens when you try to pipe it as a response due to the fact that the results are not getting JSON.stringified as they would on a query cursor
Expected Behavior
No response
Tasks
The text was updated successfully, but these errors were encountered: