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)
| 317 | |
| 318 | // setOldRevisionJSONBody stores the raw JSON body of a revision that has been archived to a separate doc. |
| 319 | func (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 | |
| 332 | func (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) |