Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3138

Export ObjectID's internal buffer

    • Type: Icon: Improvement Improvement
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: js-bson

      When working with other serialization formats, like protobuf, it would be nice to have direct access to ObjectID's internal buffer property.

      As seen in this code line (https://github.com/mongodb/js-bson/blob/1576fd0bc454b869b6445ac58e27810a7a221cb3/src/objectid.ts#L49 ), property/symbol `id` is marked as `private`.

      This implies in conversion from hex string after calling the method `toHexString`, unnecessarily:

      let buffer = Buffer.from(objectId.toHexString(), 'hex')

      So, my proposal is to remove the `private` modifier of `id`property, or to implement a method `toBuffer`.

      I can develop it and make a PR if you think it is nice to have.

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            gustavo@midianoalvo.com.br Gustavo Gondim
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: