I am looking at the example of updating record using UDF.
var count = 0;
var options = { UDF : {module: 'scan', funcname: 'updateRecord'} }
var scanBackground = client.query(argv.namespace, argv.set, options );
var scanStream = scanBackground.execute();
scanStream.on('error', function(err){
console.log(err);
});
All looks great, however this example missing a crucial example and that is how do I pass arguments to that function to update the said record?
Never mind, for future readers. Here’s how you would modify that example to do an update with arguments.
var count = 0;
var options = { UDF : {module: ‘scan’, funcname: ‘updateRecord’, args : [‘variable1’,'variable’2] } }
var scanBackground = client.query(argv.namespace, argv.set, options );
var scanStream = scanBackground.execute();
scanStream.on(‘error’, function(err){
console.log(err);
});
and your UDF should be now
function udpateRecord(rec,var1,var2)
rec[‘i’] = rec[‘i’]+1 + var1 + var2;
aerospike:update(rec);
end
1 Like