space_object:frommap()
-
object
space_object
¶ -
space_object:
frommap
(map[, option])¶ Convert a map to a tuple instance or to a table. The map must consist of “field name = value” pairs. The field names and the value types must match names and types stated previously for the space, via space_object:format().
Parameters: - space_object (
space_object
) – an object reference - map (
field-value-pairs
) – a series of “field = value” pairs, in any order. - option (
boolean
) – the only legal option is{table = true|false}
;
if the option is omitted or if{table = false}
, then return type will be ‘cdata’ (i.e. tuple);
if{table = true}
, then return type will be ‘table’.
Return: a tuple instance or table.
Rtype: tuple or table
Possible errors:
space_object
does not exist or has no format; “unknown field”.Example:
-- Create a format with two fields named 'a' and 'b'. -- Create a space with that format. -- Create a tuple based on a map consistent with that space. -- Create a table based on a map consistent with that space. tarantool> format1 = {{name='a',type='unsigned'},{name='b',type='scalar'}} --- ... tarantool> s = box.schema.create_space('test', {format = format1}) --- ... tarantool> s:frommap({b = 'x', a = 123456}) --- - [123456, 'x'] ... tarantool> s:frommap({b = 'x', a = 123456}, {table = true}) --- - - 123456 - x ...
- space_object (
-