[GODRIVER-163] Design and write first-draft of bson.Encoder Created: 14/Dec/17  Updated: 12/Apr/18  Resolved: 30/Jan/18

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

Type: New Feature Priority: Major - P3
Reporter: Kristofer Brandow (Inactive) Assignee: Kristofer Brandow (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by GODRIVER-179 Add testing for bson.Encoder Closed
Related
is related to GODRIVER-363 BSON encode and decoder do not suppor... Closed
Epic Link: GODRIVER New BSON

 Description   

The bson.Encoder is responsible for encoding the provided type into an io.Writer.

The steps are as follows:

  1. Determine if the provided type implements the bson.Marshaler interface, if it does call the MarshalBSON method and we're done
  2. Reflect the type and determine the elements to create, using struct tags if available.
  3. Incrementally build up a builder.DocumentBuilder through this process, then write the finished document to the io.Writer

Add custom types for Binary, Undefined, ObjectId, Timestamp, Null, Regex, DBPointer, Javascript, Symbol, CodeWithScope, and Min/Max key.

Support all the types that mgo/bson supports: json.Number, time.Time, and url.URL.

Support struct tags from mgo/bson: omitempty, minsize, and inline. Add support for specifying the type as a struct tag.

For the ObjectId type: use SHA256 for generating the machine identifier.



 Comments   
Comment by Kristofer Brandow (Inactive) [ 24/Jan/18 ]

https://review.gerrithub.io/c/394581/

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