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

Method HasCurrentVersion

db/document.go:1439–1452  ·  view source on GitHub ↗

HasCurrentVersion Compares the specified CV with the fetched documents CV, returns error on mismatch between the two

(ctx context.Context, cv Version)

Source from the content-addressed store, hash-verified

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 {
1440 if d.HLV == nil {
1441 return base.RedactErrorf("no HLV present in fetched doc %s", base.UD(d.ID))
1442 }
1443
1444 // fetch the current version for the loaded doc and compare against the CV specified in the IDandCV key
1445 fetchedDocSource, fetchedDocVersion := d.HLV.GetCurrentVersion()
1446 if fetchedDocSource != cv.SourceID || fetchedDocVersion != cv.Value {
1447 base.DebugfCtx(ctx, base.KeyCRUD, "mismatch between specified current version and fetched document current version for doc %s", base.UD(d.ID))
1448 // return not found as specified cv does not match fetched doc cv
1449 return base.ErrNotFound
1450 }
1451 return nil
1452}
1453
1454// SetAttachments updates the attachments metadata for the document.
1455func (d *Document) SetAttachments(attachments AttachmentsMeta) {

Callers 2

getCurrentVersionMethod · 0.80
getCurrentVersionMethod · 0.80

Calls 4

RedactErrorfFunction · 0.92
UDFunction · 0.92
DebugfCtxFunction · 0.92
GetCurrentVersionMethod · 0.80

Tested by 1

getCurrentVersionMethod · 0.64