How to add a bin with value to existing key

python

#1

Hi

Is there a way to add a (bin, value) to existing key in atomic way.

For example there is a key with data

'bin1': 'value1'

and by doing something similar to client.add_bin(key, ‘bin2’, ‘value2’) get

'bin1': 'value1'
'bin2': 'value2'

without reading all the key record and putting back with updated bin info.

I saw that Aersopike client does have “remove_bin” function, I wondering will it have add_bin?

Thanks.


#2

You have described the default behavior. The only time the existing record isn’t merged with the new write is when the write policy is set to replace.


#3

I saw that Aersopike client does have “remove_bin” function, I wondering will it have add_bin?

This is done by sending a NULL value for the bin.


#4

A bin is added automatically when you write a bin-name/bin-value pair that doesn’t yet exist. Removing it is done via sending a null, or in the case of the ‘bin remove’ that’s a helper that sends the null for you.