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

Method BodyWithSpecialProperties

db/document.go:338–363  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

336}
337
338func (doc *Document) BodyWithSpecialProperties(ctx context.Context) ([]byte, error) {
339 bodyBytes, err := doc.BodyBytes(ctx)
340 if err != nil {
341 return nil, err
342 }
343
344 kvPairs := []base.KVPair{
345 {Key: BodyId, Val: doc.ID},
346 {Key: BodyRev, Val: doc.GetRevTreeID()},
347 }
348
349 if doc.IsDeleted() {
350 kvPairs = append(kvPairs, base.KVPair{Key: BodyDeleted, Val: true})
351 }
352
353 if len(doc.Attachments()) > 0 {
354 kvPairs = append(kvPairs, base.KVPair{Key: BodyAttachments, Val: doc.Attachments()})
355 }
356
357 bodyBytes, err = base.InjectJSONProperties(bodyBytes, kvPairs...)
358 if err != nil {
359 return nil, err
360 }
361
362 return bodyBytes, nil
363}
364
365// Returns a new empty document.
366func NewDocument(docid string) *Document {

Callers 1

updateAndReturnDocMethod · 0.80

Calls 5

BodyBytesMethod · 0.95
IsDeletedMethod · 0.95
AttachmentsMethod · 0.95
InjectJSONPropertiesFunction · 0.92
GetRevTreeIDMethod · 0.45

Tested by

no test coverage detected