Loading…
![]() String updated in the repository testing_project / Documentation: reference/reference_lua/key_def — Russian |
Glossary
English | Russian | ||
---|---|---|---|
No related strings found in the glossary. |
Loading…
![]() String updated in the repository testing_project / Documentation: reference/reference_lua/key_def — Russian |
English | Russian | ||
---|---|---|---|
No related strings found in the glossary. |
-- extracting the tuples' primary-key values, so they could be deleted
-- using a unique index. This code should be a part of a Lua function.
local key_def_lib = require('key_def')
local s = box.schema.space.create('test')
local pk = s:create_index('pk')
local sk = s:create_index('test', {unique = false, parts = {
{2, 'number', path = 'a'}, {2, 'number', path = 'b'}}})
s:insert{1, {a = 1, b = 1}}
s:insert{2, {a = 1, b = 2}}
local key_def = key_def_lib.new(pk.parts)
for _, tuple in sk:pairs({1})) do
local key = key_def:extract_key(tuple)
pk:delete(key)
end
-- и извлекаем из них значения по первичному ключу.
-- Затем удаляем значения, используя уникальный индекс.
-- Этот код должен входить в Lua-функцию.
local key_def_lib = require('key_def')
local s = box.schema.space.create('test')
local pk = s:create_index('pk')
local sk = s:create_index('test', {unique = false, parts = {
{2, 'number', path = 'a'}, {2, 'number', path = 'b'}}})
s:insert{1, {a = 1, b = 1}}
s:insert{2, {a = 1, b = 2}}
local key_def = key_def_lib.new(pk.parts)
for _, tuple in sk:pairs({1})) do
local key = key_def:extract_key(tuple)
pk:delete(key)
end