I am calling a Lua script from nodejs. I want to pass an array as argument. I am facing problem to parse that array in Lua.
Below is an example:
var script = 'local actorlist = ARGV[1]
if #actorlist > 0 then
for i, k in ipairs(actorlist) do
redis.call("ZADD","key", 1, k)
end
end';
client.eval(
script, //lua source
0,
['keyv1','keyv2']
function(err, result) {
console.log(err+'------------'+result);
}
);
It gives me this error:
"ERR Error running script (call to f_b263a24560e4252cf018189a4c46c40ce7d1b21a): @user_script:1: user_script:1: bad argument #1 to 'ipairs' (table expected, got string)
ARGV[1]suppose to be? How does it get its value? eg. is it a string containing comma separated list of actors?ARGVorKEYScalled withclient.eval(script, 2, ...eval. Is there a reason for not unpacking the array first and passing them in as separate arguments?