MCPcopy Create free account
hub / github.com/google/go-cloud / encodeDoc

Function encodeDoc

docstore/mongodocstore/codec.go:34–40  ·  view source on GitHub ↗

Encode and decode to map[string]interface{}. This isn't ideal, because the mongo client encodes/decodes a second time. TODO(jba): Benchmark the double decode to see if it's worth trying to avoid it. This code is copied from memdocstore/codec.go, except for special treatment of primitive.Binary.

(doc driver.Document, lowercaseFields bool)

Source from the content-addressed store, hash-verified

32// primitive.Binary.
33
34func encodeDoc(doc driver.Document, lowercaseFields bool) (map[string]interface{}, error) {
35 e := encoder{lowercaseFields: lowercaseFields}
36 if err := doc.Encode(&e); err != nil {
37 return nil, err
38 }
39 return e.val.(map[string]interface{}), nil
40}
41
42func encodeValue(x interface{}) (interface{}, error) {
43 var e encoder

Callers 2

encodeDocMethod · 0.70
DocstoreEncodeMethod · 0.70

Calls 1

EncodeMethod · 0.45

Tested by 1

DocstoreEncodeMethod · 0.56