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

Update NewDocument to take a variadic list of *Elements

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 0.0.1
    • Affects Version/s: None
    • Component/s: None
    • None

      Currently the NewDocument function takes a uint which is used as the initial capacity for the slices of the *Document. This was done primarily to enable users to allocate a single array upfront and then append to it later.

      Instead of doing it that way, update NewDocument to take a variadic list of *Elements. If a user wishes to control allocations, they can first make a []*Element, fill it with documents, and then pass that to NewDocument. In NewDocument we'll reuse the provided slice to ensure we don't allocate an extra array.

      For the majority of use cases, this change will enable a more concise creation of documents.

            Assignee:
            sam.rossi@mongodb.com Samuel Rossi (Inactive)
            Reporter:
            kris.brandow@mongodb.com Kristofer Brandow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: