How to find documents and NOT convert all _ids to String in MongoDB

40 Views Asked by At

Whenever you use collenction.find({}) all fields that contain ids like {"$oid": "64e6fb236049651f4cebdc1"}, automatically get converted to String "64e6fb236049651f4cebdc1".

Is it possible to make MongoDB keep all ids in their object form when finding documents? (in node.js)

I am aware that you can convert individual ids back to an object using MongoDB.ObjectID(string) but that's not what I need because in my case all objects have different structure and have multiple fields containing ids.

I tried Googling it but all I got was answers to similar sounding but different questions. I tried reading the docs for mongodb find and findOptions text but it seems like there isn't anything that can help

0

There are 0 best solutions below