-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: BSON
-
None
Even though it's not in the official specifications for the ObjectId. Adding a _dict_ method would help serve DB's data through a rest API without having to parse "id" every time potentially slowing the code and also potentially forgetting to parse the documents resulting in errors that make the API route unusable. __ Adding __ a __ __dict_ method is not that hard, Copy-pasting the str method and making a few changes should be enough.
I made a simple gist, that should be working, although I haven't tested it yet, I might do a PR tomorrow if it works. (This should be implemented in the main ObjectId class, not a separate one like the gist I made)
https://gist.github.com/ticua07/10bd5795dd379c2df26509f1aed6d49f