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

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -