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

Method setOldRevisionJSONBody

db/revision.go:319–330  ·  view source on GitHub ↗

setOldRevisionJSONBody stores the raw JSON body of a revision that has been archived to a separate doc.

(ctx context.Context, docid string, rev string, body []byte, expiry uint32)

Source from the content-addressed store, hash-verified

317
318// setOldRevisionJSONBody stores the raw JSON body of a revision that has been archived to a separate doc.
319func (db *DatabaseCollectionWithUser) setOldRevisionJSONBody(ctx context.Context, docid string, rev string, body []byte, expiry uint32) error {
320 // Setting the binary flag isn't sufficient to make N1QL ignore the doc - the binary flag is only used by the SDKs.
321 // To ensure it's not available via N1QL, need to prefix the raw bytes with non-JSON data.
322 nonJSONBytes := withNonJSONPrefix(nonJSONPrefixKindRevBody, body)
323 err := db.dataStore.SetRaw(oldRevisionKey(docid, rev), expiry, nil, nonJSONBytes)
324 if err == nil {
325 base.DebugfCtx(ctx, base.KeyCRUD, "Backed up revision body %q/%q (%d bytes, ttl:%d)", base.UD(docid), rev, len(body), expiry)
326 } else {
327 base.WarnfCtx(ctx, "setOldRevisionJSONBody failed: doc=%q rev=%q err=%v", base.UD(docid), rev, err)
328 }
329 return err
330}
331
332func (db *DatabaseCollectionWithUser) setOldRevisionJSON(ctx context.Context, docid string, rev string, body []byte, deletedDoc bool, expiry uint32, channels base.Set) error {
333 // no channel information available (Note: this is different than an empty set of channels)

Calls 6

DebugfCtxFunction · 0.92
UDFunction · 0.92
WarnfCtxFunction · 0.92
withNonJSONPrefixFunction · 0.85
oldRevisionKeyFunction · 0.85
SetRawMethod · 0.45