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

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Won't Fix
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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

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

              Created:
              Updated:
              Resolved: