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

Method GetMetaMap

db/document.go:448–466  ·  view source on GitHub ↗

Builds the Meta Map for use in the Sync Function. This meta map currently only includes the user xattr, however, this can be expanded upon in the future. NOTE: emptyMetaMap() is used within tests in channelmapper_test.go and therefore this should be expanded if the below is

(userXattrKey string)

Source from the content-addressed store, hash-verified

446// can be expanded upon in the future.
447// NOTE: emptyMetaMap() is used within tests in channelmapper_test.go and therefore this should be expanded if the below is
448func (doc *Document) GetMetaMap(userXattrKey string) (map[string]interface{}, error) {
449 xattrsMap := map[string]interface{}{}
450
451 if userXattrKey != "" {
452 var userXattr interface{}
453
454 if len(doc.rawUserXattr) > 0 {
455 err := base.JSONUnmarshal(doc.rawUserXattr, &userXattr)
456 if err != nil {
457 return nil, err
458 }
459 }
460 xattrsMap[userXattrKey] = userXattr
461 }
462
463 return map[string]interface{}{
464 base.MetaMapXattrsKey: xattrsMap,
465 }, nil
466}
467
468func (doc *Document) SetCrc32cUserXattrHash() {
469 doc.SyncData.Crc32cUserXattr = userXattrCrc32cHash(doc.rawUserXattr)

Callers 2

getResyncedDocumentMethod · 0.80
prepareSyncFnMethod · 0.80

Calls 1

JSONUnmarshalFunction · 0.92

Tested by

no test coverage detected