tuple_object[field-name]
-
object
tuple_object¶ -
<tuple_object>[field-name]¶ If
tis a tuple instance,t['field-name']will return the field named ‘field-name’ in the tuple. Fields have names if the tuple has been retrieved from a space that has an associated format.t[lua-variable-name]will do the same thing iflua-variable-namecontains'field-name'.There is a variation which the Lua manual calls “syntactic sugar”: use
t.field-nameas an equivalent oft['field-name'].Return: field value. Rtype: lua-value In the following example, a tuple named
tis returned fromreplaceand then the second field intnamed ‘field2’ is returned.tarantool> format = {} --- ... tarantool> format[1] = {name = 'field1', type = 'unsigned'} --- ... tarantool> format[2] = {name = 'field2', type = 'string'} --- ... tarantool> s = box.schema.space.create('test', {format = format}) --- ... tarantool> pk = s:create_index('pk') --- ... tarantool> t = s:replace{1, 'Я'} --- ... tarantool> t['field2'] --- - Я ...
-