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 (*bucket) update

func (b *bucket) update(k string, exp int, callback updatefunc) error 

update 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

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

Error while updating a record in APEX screen -

c++ - In an add-in in Excel, written in C(++), how does one get the name of the function which called into the addin? -