WriteMetadataDocument writes a metadata document, and fails on CAS mismatch
(ctx context.Context, location, docID string, cas uint64, value interface{})
| 325 | |
| 326 | // WriteMetadataDocument writes a metadata document, and fails on CAS mismatch |
| 327 | func (cc *CouchbaseCluster) WriteMetadataDocument(ctx context.Context, location, docID string, cas uint64, value interface{}) (newCAS uint64, err error) { |
| 328 | if cc == nil { |
| 329 | return 0, errors.New("nil CouchbaseCluster") |
| 330 | } |
| 331 | if cas == 0 { |
| 332 | return 0, RedactErrorf("CAS for %q in bucket %q must be non-zero to call WriteMetadataDocument, to add a new document use InsertMetadataDocument", MD(docID), MD(location)) |
| 333 | } |
| 334 | |
| 335 | b, teardown, err := cc.getBucket(ctx, location) |
| 336 | if err != nil { |
| 337 | return 0, err |
| 338 | } |
| 339 | defer teardown() |
| 340 | |
| 341 | rawDocument, err := JSONMarshal(value) |
| 342 | if err != nil { |
| 343 | return 0, err |
| 344 | } |
| 345 | |
| 346 | casOut, err := cc.configPersistence.replaceRawConfig(b.DefaultCollection(), docID, rawDocument, gocb.Cas(cas)) |
| 347 | return uint64(casOut), err |
| 348 | } |
| 349 | |
| 350 | func (cc *CouchbaseCluster) TouchMetadataDocument(ctx context.Context, location, docID string, property, value string, cas uint64) (newCAS uint64, err error) { |
| 351 |
nothing calls this directly
no test coverage detected