Updated at July 17, 2026 02:08 PM
space_object extensions
You can extend space_object with custom functions as follows:
- Create a Lua function.
- Add the function name to a predefined global variable
box.schema.space_mt, which has thetabletype. Adding tobox.schema.space_mtmakes the function available for all spaces. - Call the function on the
space_object:space_object:function-name([parameters]).
Alternatively, you can make a user-defined function available for only
one space by calling getmetatable(space_object) and then adding the
function name to the meta table.
See also:
/reference/reference_lua/box_index/user_defined.
Example:
-- Visible to any space, no parameters.-- After these requests, the value of global_variable will be 6.box.schema.space.create('t')box.space.t:create_index('i')global_variable = 5function f(space_arg) global_variable = global_variable + 1 endbox.schema.space_mt.counter = fbox.space.t:counter()