Skip to content

Instantly share code, notes, and snippets.

@adamcfraser
Created March 31, 2017 22:12
Show Gist options
  • Save adamcfraser/1a8c35b9a741f1484f9db75b42eaaf86 to your computer and use it in GitHub Desktop.
Save adamcfraser/1a8c35b9a741f1484f9db75b42eaaf86 to your computer and use it in GitHub Desktop.
// Create a document with a system xattr
xattr := "_sync"
k := "foo"
v := make(map[string]interface{})
v["body_field"] = "1234"
xv := make(map[string]interface{})
xv["seq"] = 123
xv["rev"] = "1-1234"
newCas, err := bucket.Insert(k, &val, uint32(0))
docFragment, err := bucket.MutateIn(k, newCas, uint32(exp)).
UpsertEx(xattr, xv, gocb.SubdocFlagXattr|gocb.SubdocFlagCreatePath).
Execute()
// Delete the document
bucket.Remove(k, 0)
// Attempt to retrieve the xattr for the deleted document. Returns error, no xattr in res.
accessDeletedFlag := gocb.SubdocFlag(0x08)
res, err := bucket.Bucket.LookupIn(k).
GetEx(xattr, accessDeletedFlag|gocb.SubdocFlagXattr).
Execute()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment