如果您要修改地图的键或列表的索引,则应将该 bin 转换为局部变量,然后在更新之前将其设置回记录。
function changes(rec)
rec['i'] = 99
local m = rec['m']
m['a'] = 66
rec['m'] = m
aerospike:update(rec)
end
在 AQL 中
$ aql
Aerospike Query Client
Version 3.15.1.2
C Client Version 4.3.0
Copyright 2012-2017 Aerospike. All rights reserved.
aql> register module './test.lua'
OK, 1 module added.
aql> select * from test.demo where PK='88'
+----+-------+--------------------------------------+------------------------------------------+
| i | s | m | l |
+----+-------+--------------------------------------+------------------------------------------+
| 88 | "xyz" | MAP('{"a":2, "b":4, "c":8, "d":16}') | LIST('[2, 4, 8, 16, 32, NIL, 128, 256]') |
+----+-------+--------------------------------------+------------------------------------------+
1 row in set (0.002 secs)
aql> execute test.changes() on test.demo where PK='88'
+---------+
| changes |
+---------+
| |
+---------+
1 row in set (0.001 secs)
aql> select * from test.demo where PK='88'
+----+-------+---------------------------------------+------------------------------------------+
| i | s | m | l |
+----+-------+---------------------------------------+------------------------------------------+
| 99 | "xyz" | MAP('{"a":66, "b":4, "c":8, "d":16}') | LIST('[2, 4, 8, 16, 32, NIL, 128, 256]') |
+----+-------+---------------------------------------+------------------------------------------+
1 row in set (0.000 secs)