In NodeJS, I have an aggregate MongoDB query with ObjectIDs. I'm simply trying to output the query to a string (e.g. console.log) so that I can copy/paste it into a console and run the query manually.
I can't find any method on the query itself so I'm doing a console.log on the pipeline json.
console.log(JSON.stringify(pipeline));
Which outputs:
[{"$match":{"$and":[{"users.userId":{"$eq":{"_bsontype":"ObjectID","id":{"type":"Buffer","data":[93,151,104,127,56,207,132,25,197,44,232,49]}}}},{"users.userId":{"$eq":{"_bsontype":"ObjectID","id":{"type":"Buffer","data":[93,151,104,127,56,207,132,25,197,44,232,49]}}}}]}}]
This is the result I'm hoping for which runs successfully in the console:
[{"$match":{"$and":[{"users.userId":{"$eq":ObjectId("5d97687f38cf8419c52ce831")}},{"users.userId":{"$eq":ObjectId("5d97687f38cf8419c52ce831")}}]}}]```