Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-3394

Add __dict__ method to ObjectId class

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 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

            Assignee:
            Unassigned Unassigned
            Reporter:
            ticua@ticua.ar ticua ticua
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: