How to delete a single bin from set?

Hello

I’m using python client,i want to delete a single bin from my set,please provide solution.

ThanksScreenshot from 2017-08-23 17-21-02

In this records i want to delete ‘level’ bin from set

In the Python client you assign the bin you want to delete (in this case ‘level’) with the value aerospike.null().

However, if every record in a set has a bin you want to remove, it would be more efficient to remove the record using a record UDF that assigns the Lua value nil to this bin. You would then apply the function to each record in the set, for example from AQL.

fix.lua

function del_level(rec)
  rec['level'] = nil
  aerospike:update(rec)
end

In AQL:

$ aql
Aerospike Query Client
Version 3.12.0
C Client Version 4.1.4
Copyright 2012-2017 Aerospike. All rights reserved.
aql> register module './fix.lua'
OK, 1 module added.

aql> execute fix.del_level() on test.foo
3 Likes

@rbotzer, is there any python aerospike method to do the same thing?

See https://www.aerospike.com/apidocs/python/client.html?highlight=apply#aerospike.Client.scan_apply

1 Like