Reputation: 3157
Each time I have to perform a query involving _id, I have to do new ObjectID( _idAsString) in order for it to work. I realize mongo tests the object, not the value itself, but this is adding a lot of overhead and I may miss converting it in some places.
The _id goes to the client where the ObjectID( string ) is turned to string and when it comes back from the client, I would have to remake it into ObjectID( string ). I will mention that "string" is the actual value generated by mongo, something like 123a1b12dc...
If there is another good/complete library with such a internal functionality, I would love to try it out.
Upvotes: 0
Views: 180
Reputation: 23070
There are some Node.js object mappers which provide this functionality. Take a look at Mongolia.
https://github.com/masylum/mongolia#mappings-and-type-casting
Upvotes: 1