lia.db
Helper library for managing database.
Functions
connect(callback, reconnect)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Establishes a connection to the database module specified in the configuration. If the database is not connected yet or if reconnection is forced, it connects to the database module.
Parameters
-
callback
Function
optional
A function to be called after the database connection is established.
-
reconnect
Boolean
optional
Whether to force a reconnection to the database module.
convertDataType(value, noEscape)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Converts a Lua value to a format suitable for insertion into the database.
Parameters
-
value
The value to be converted.
-
noEscape
Boolean
optional
Whether to skip escaping the value. Defaults to false.
Returns
-
string
The converted value suitable for database insertion.
delete(dbTable, condition)
Deletes rows from the specified database table based on the given condition.
Parameters
-
dbTable
String
The name of the database table. Defaults to "character".
-
condition
Function
optional
The condition to apply to the deletion.
Returns
-
Deferred
A deferred object that resolves to a table containing the deletion results and the last inserted ID.
insertTable(value, callback, dbTable)
Inserts a new row into the specified database table with the provided values.
Parameters
-
value
The values to be inserted into the table.
-
callback
Function
optional
A function to be called after the insertion operation is completed.
-
dbTable
String
optional
The name of the database table. Defaults to "characters".
loadTables()
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Loads the necessary tables into the database.
select(fields, dbTable, condition, limit)
Selects data from the specified database table based on the provided fields, condition, and limit.
Parameters
-
fields
Table
The fields to select from the table.
-
dbTable
String
optional
The name of the database table. Defaults to "characters".
-
condition
Function
optional
The condition to apply to the selection.
-
limit
Integer
optional
[ The maximum number of rows to retrieve.
Returns
-
Deferred
A deferred object that resolves to a table containing the selected results and the last inserted ID.
updateTable(value, callback, dbTable, condition)
Updates rows in the specified database table with the provided values based on the given condition.
Parameters
-
value
The values to be updated in the table.
-
callback
Function
optional
A function to be called after the update operation is completed.
-
dbTable
String
optional
The name of the database table. Defaults to "characters".
-
condition
Function
optional
The condition to apply to the update operation.
upsert(value, dbTable)
Inserts or updates rows in the specified database table with the provided values.
Parameters
-
value
The values to be inserted or updated in the table.
-
dbTable
String
The name of the database table. Defaults to "characters".
Returns
-
Deferred
A deferred object that resolves to a table containing the insertion or update results and the last inserted ID.
waitForTablesToLoad()
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Waits for the database tables to be loaded.
Returns
-
Deferred
A deferred object that resolves when the tables are loaded.
wipeTables(callback)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Wipes all Lilia-related tables in the database.
Parameters
-
callback
Function
optional
A function to be called after the wipe operation is completed.