LLIST bin essentially stores KEY->VALUE pair (Implemented as B+tree in server). When you pass a map type data to LLIST, it looks for keyword key and uses it as KEY sort and passed in data in entirety as VALUE.
Now if you want to update something in the LLIST you need to specify KEY and VALUE. There is no notion of updating only subpart of VALUE.
What you are trying to do would in logic look like
- oldValue = llist.find(key)
- newValue = updateValue(oldValue)
which has fundamental problem of two round trips to the server and performing IO twice.
This can be worked around by using UDF which would look like.
local llist = required('ldt/lib_llist')
function findAndUpdate(rec, listBin, key, setValue)
if (llist.ldt_exists(rec, listBin)) then
local rc = 1;
local oldValue = llist.find(rec, listBin, key)
if (oldValue ~= nil) then
oldValue['value'] = setValue;
rc = llist.update(rec, listBin, oldValue);
This function would return 0 in case of success and nonzero in case of failure.
Invocation of this from aql would look like
aql > register module 'listExtension.lua'
aql > execute findAndUpdate('mylist', 0, 86) on test.demo where PK='1'
Note: first parameter which is rec is implicit in UDF system passes it. Others you have to pass.