tuple_object:format() | Tarantool
Документация на русском языке
поддерживается сообществом

tuple_object:format()

object tuple_object
tuple_object:format()

Get the format of a tuple. The resulting table lists the fields of a tuple (their names and types) if the format option was specified during the tuple creation. Otherwise, the return value is empty.

Return:the tuple format.
Rtype:table

Примечание

tuple_object.format() is equivalent to box.tuple.format(tuple_object).

Example:

  • A formatted tuple:

    tarantool> f = box.tuple.format.new({{'id', 'number'}, {'name', 'string'}})
    ---
    ...
    
    tarantool> ftuple = box.tuple.new({1, 'Bob'}, {format = f})
    ---
    ...
    
    tarantool> ftuple:format()
    ---
    - [{'name': 'id', 'type': 'number'}, {'name': 'name', 'type': 'string'}]
    ...
    
    tarantool> box.tuple.format(ftuple)
    ---
    - [{'name': 'id', 'type': 'number'}, {'name': 'name', 'type': 'string'}]
    ...
    
  • A tuple without a format:

    tarantool> tuple1 = box.tuple.new({1, 'Bob'}) -- no format
    ---
    ...
    
    tarantool> tuple1:format()
    ---
    - []
    ...
    
    tarantool> box.tuple.format(tuple1)
    ---
    - []
    ...
    
Нашли ответ на свой вопрос?
Обратная связь