[GODRIVER-214] Update NewDocument to take a variadic list of *Elements Created: 01/Feb/18  Updated: 28/Oct/23  Resolved: 01/Feb/18

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 0.0.1

Type: Improvement Priority: Major - P3
Reporter: Kristofer Brandow (Inactive) Assignee: Samuel Rossi (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: GODRIVER New BSON

 Description   

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.


Generated at Thu Feb 08 08:33:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.