Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-474

Expose Cursor.Peek() function to know how much space a document will require

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None

    Description

      It would be convenient to expose a Peek function for Cursor, so that, if one is interested in allocating a byte slice to accommodate the Decode(), they can do it. Otherwise, we have to guess-timate the size of the byte slice to pass to Decode, or look for NewErrTooSmall errors, which is not optimal.

      relevant code: https://github.com/mongodb/mongo-go-driver/blob/2bc72ab2a7bf23f6f53554e9cf48b061943d664e/bson/decode.go#L181-L197

      Attachments

        Activity

          People

            Unassigned Unassigned
            gpean Gregoire Pean
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: