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

Function computeMetadataOnlyUpdate

db/document.go:1421–1436  ·  view source on GitHub ↗

computeMetadataOnlyUpdate computes a new metadataOnlyUpdate based on the existing document's CAS and metadataOnlyUpdate

(currentCas uint64, revNo uint64, currentMou *MetadataOnlyUpdate)

Source from the content-addressed store, hash-verified

1419
1420// computeMetadataOnlyUpdate computes a new metadataOnlyUpdate based on the existing document's CAS and metadataOnlyUpdate
1421func computeMetadataOnlyUpdate(currentCas uint64, revNo uint64, currentMou *MetadataOnlyUpdate) *MetadataOnlyUpdate {
1422 var prevCas string
1423 currentCasString := base.CasToString(currentCas)
1424 if currentMou != nil && currentCasString == currentMou.HexCAS {
1425 prevCas = currentMou.PreviousHexCAS
1426 } else {
1427 prevCas = currentCasString
1428 }
1429
1430 metadataOnlyUpdate := &MetadataOnlyUpdate{
1431 HexCAS: expandMacroCASValueString, // when non-empty, this is replaced with cas macro expansion
1432 PreviousHexCAS: prevCas,
1433 PreviousRevSeqNo: revNo,
1434 }
1435 return metadataOnlyUpdate
1436}
1437
1438// HasCurrentVersion Compares the specified CV with the fetched documents CV, returns error on mismatch between the two
1439func (d *Document) HasCurrentVersion(ctx context.Context, cv Version) error {

Callers 2

ResyncDocumentMethod · 0.85
importDocMethod · 0.85

Calls 1

CasToStringFunction · 0.92

Tested by

no test coverage detected