MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / Body

Method Body

db/document.go:371–393  ·  view source on GitHub ↗

Accessors for document properties. To support lazy unmarshalling of document contents, all access should be done through accessors

(ctx context.Context)

Source from the content-addressed store, hash-verified

369
370// Accessors for document properties. To support lazy unmarshalling of document contents, all access should be done through accessors
371func (doc *Document) Body(ctx context.Context) Body {
372 var caller string
373 if base.ConsoleLogLevel().Enabled(base.LevelTrace) {
374 caller = base.GetCallersName(1, true)
375 }
376
377 if doc._body != nil {
378 base.TracefCtx(ctx, base.KeyAll, "Already had doc body %s/%s from %s", base.UD(doc.ID), base.UD(doc.RevID), caller)
379 return doc._body
380 }
381
382 if doc._rawBody == nil {
383 return nil
384 }
385
386 base.TracefCtx(ctx, base.KeyAll, " UNMARSHAL doc body %s/%s from %s", base.UD(doc.ID), base.UD(doc.RevID), caller)
387 err := doc._body.Unmarshal(doc._rawBody)
388 if err != nil {
389 base.WarnfCtx(ctx, "Unable to unmarshal document body from raw body : %s", err)
390 return nil
391 }
392 return doc._body
393}
394
395// Get a deep mutable copy of the body, using _rawBody. Initializes _rawBody based on _body if not already present.
396func (doc *Document) GetDeepMutableBody() (Body, error) {

Callers 15

WaitForDocVersionMethod · 0.95
WaitForCVMethod · 0.95
BenchmarkHandleRevDeltaFunction · 0.95
BenchmarkUnmarshalBodyFunction · 0.95
processRevMethod · 0.95
handleSyncFnDryRunMethod · 0.45
TestPutInvalidAttachmentFunction · 0.45

Calls 7

ConsoleLogLevelFunction · 0.92
GetCallersNameFunction · 0.92
TracefCtxFunction · 0.92
UDFunction · 0.92
WarnfCtxFunction · 0.92
EnabledMethod · 0.45
UnmarshalMethod · 0.45