box.atomic()
- 
 box.atomic([opts, ]tx-function[, function-arguments])¶
- Выполнение функции так, как будто функция начинается с явного вызова box.begin() и заканчивается неявным вызовом box.commit() после успешного выполнения или же заканчивается неявным вызовом box.rollback() в случае ошибки. - Параметры: - opts (table) –(optional) transaction options: - txn_isolation– the transaction isolation level
- timeout– a timeout (in seconds), after which the transaction is rolled back
 
- tx-function (string) – the function name
- function-arguments – (optional) arguments passed to the function
 - возвращает: - the result of the function passed to - atomic()as an argument- Возможные ошибки: - ошибка и прерывание транзакции в случае конфликта.
- error and abort the transaction if the timeout is exceeded.
- ошибка, если операция не может выполнить запись на диск.
- ошибка, если по какой-либо причине нельзя выделить память.
 - Example - -- Create an index with the specified sequence -- box.schema.sequence.create('id_sequence', { min = 1 }) box.space.bands:create_index('primary', { parts = { 'id' }, sequence = 'id_sequence' }) -- Insert test data -- box.space.bands:insert { 1, 'Roxette', 1986 } box.space.bands:insert { 2, 'Scorpions', 1965 } box.space.bands:insert { 3, 'Ace of Base', 1987 } -- Define a function -- local function insert_band(band_name, year) box.space.bands:insert { nil, band_name, year } end -- Begin and commit the transaction implicitly -- box.atomic(insert_band, 'The Beatles', 1960) -- Begin the transaction with the specified isolation level -- box.atomic({ txn_isolation = 'read-committed' }, insert_band, 'The Rolling Stones', 1962) 
- opts (