go-couchbase client Update function -
i using update function of go-couchbase
//defining function first , passing argument myfunc := func(current []byte)(updated []byte, err error) {return updated, err } myb.update("key123", 1, myfunc) however, when run update function of bucket. checked couch database. document key of "key123" disappeared. seems update not update value delete it. happened? doing not correct?
func (b *bucket) update(k string, exp int, callback updatefunc) errorupdate performs safe update of document, avoiding conflicts using cas.
the callback function invoked current raw document contents (or nil if document doesn't exist); should return updated raw contents (or nil delete.) if decides not change can return updatecancel error.
if writer modifies document between , set, callback invoked again newer value.
your updatefunc:
myfunc := func(current []byte)(updated []byte, err error) {return updated, err } you not set updated []byte value before return it. therefore, has 0 value nil, request delete: "the callback function should return updated raw contents (or nil delete.)"
Comments
Post a Comment