Tips on Lua syntax | Tarantool
Документация на русском языке
поддерживается сообществом
Tips on Lua syntax

Tips on Lua syntax

The Lua syntax for data-manipulation functions can vary. Here are examples of the variations with select() requests. The same rules exist for the other data-manipulation functions.

Every one of the examples does the same thing: select a tuple set from a space named „tester“ where the primary-key field value equals 1. For these examples, we assume that the numeric id of „tester“ is 512, which happens to be the case in our sandbox example only.

First, there are three object reference variations:

-- #1 module . submodule . name
-- #2 replace name with a literal in square brackets
-- #3 use a variable for the entire object reference
tarantool> s =
tarantool> s:select{1}

Examples in this manual usually have the «» form (#1). However, this is a matter of user preference and all the variations exist in the wild.

Also, descriptions in this manual use the syntax «space_object:» for references to objects which are spaces, and «index_object:» for references to objects which are indexes (for example

Then, there are seven parameter variations:

-- #1
-- #2
-- #3
-- #4
-- #5
-- #6
tarantool> variable = 1
-- #7
tarantool> variable = {1}

Lua allows to omit parentheses () when invoking a function if its only argument is a Lua table, and we use it sometimes in our examples. This is why select{1} is equivalent to select({1}). Literal values such as 1 (a scalar value) or {1} (a Lua table value) may be replaced by variable names, as in examples #6 and #7. Although there are special cases where braces can be omitted, they are preferable because they signal «Lua table». Examples and descriptions in this manual have the {1} form. However, this too is a matter of user preference and all the variations exist in the wild.

Нашли ответ на свой вопрос?
Обратная связь