Module LuaDB

Functions for mobs and players

Functions

all () get an iterator over all key/value pairs in a LuaDB.
allKeys () get an iterator over all keys in a LuaDB.
delete (key) deletes a key/value pair.
get (key) gets the value of a given key.
list () Lists the open LuaDBs.
open (name, createifmissing) Opens a LuaDB.
put (key, value) saves a key/value pair.
seek (key) get an iterator over key/value pairs in a LuaDB, starting at the designated key.
seekKey (key) get an iterator over keys in a LuaDB, starting at the designated key.
statistics () fetch statistics for a given LuaDB (work in progress)


Functions

all ()
get an iterator over all key/value pairs in a LuaDB.

Returns:

    an iterator of keys and values

Usage:

    for k,v in db:all() do
      self:echo("Key: " .. k .. ", Value: " .. v)
    end
allKeys ()
get an iterator over all keys in a LuaDB.

Returns:

    an iterator of keys

Usage:

    for k in db:allKeys() do
      self:echo("Key: " .. k)
    end
delete (key)
deletes a key/value pair.

Parameters:

  • key the key name (string, integer, or binary)

Usage:

    db:delete("a_key")
get (key)
gets the value of a given key.

Parameters:

  • key the key name (string, integer, or binary)

Returns:

    string/integer/boolean/binary the value assigned to the key

Usage:

    local val = db:get("a_key")
list ()
Lists the open LuaDBs.

Returns:

    Table a table with index numbers and the LuaDB names
open (name, createifmissing)
Opens a LuaDB. Pulls from SQL if exists or, optionally, creates if not.

Parameters:

  • name string The name of the DB to open
  • createifmissing bool Create the DB if it doesn't already exist (optional, defaults to true)

Returns:

    LuaDB the database instance

Usage:

    local db = LuaDB.open("thesithempire_clandb", true)
put (key, value)
saves a key/value pair.

Parameters:

  • key the key name (string, integer, or binary)
  • value the value to save (string, integer, boolean, or binary)

Usage:

    db:put("a_key", "a_val")
    db:put("b_key", 24601)
    db:put("c_key", true)
seek (key)
get an iterator over key/value pairs in a LuaDB, starting at the designated key.

Parameters:

  • key the key name (string, integer, or binary)

Returns:

    an iterator of keys and values

Usage:

    for k,v in db:seek("key_o") do
      self:echo("Key: " .. k .. ", Value: " .. v)
    end
seekKey (key)
get an iterator over keys in a LuaDB, starting at the designated key.

Parameters:

  • key the key name (string, integer, or binary)

Returns:

    an iterator of keys

Usage:

    for k in db:seekKey("key_o") do
      self:echo("Key: " .. k)
    end
statistics ()
fetch statistics for a given LuaDB (work in progress)

Returns:

    string statistics the statistics for the LuaDB

Usage:

    self:echo("Statistics: " .. db:statistics())
generated by LDoc 1.5.0 Last updated 2025-08-19 19:50:41