Skip to main content

Database

The Database module provides a server-side SQLite database interface for persistent data storage. Use it to store player data, inventories, leaderboards, and any other persistent state. It provides both synchronous and asynchronous methods for executing queries and retrieving results.

Authority: Server -- Database operations can only be performed on the server.


Methods

MethodParametersReturn TypeAuthorityDescription
Database.Initializepath: stringvoidServerSets the file path for the SQLite database. Only needs to be called once.
Database.Executequery: string, params: tablebooleanServerRuns a SQL command (CREATE TABLE, INSERT, UPDATE, DELETE). Returns true on success.
Database.ExecuteAsyncquery: string, params: table, callback: functionvoidServerSame as Execute, but runs in the background. The callback receives a boolean success value.
Database.Selectquery: string, params: tabletableServerRuns a SELECT query and returns a list of rows. Each row has a .Columns table with the column values.
Database.SelectAsyncquery: string, params: table, callback: functionvoidServerSame as Select, but runs in the background. The callback receives the rows table.

Examples

Initializing the Database

// Database operations are handled via Lua scripting on the server.

CRUD Operations

// CRUD operations are handled via Lua scripting on the server.

Async Select

// Async database queries are handled via Lua scripting.

warning

Never store database credentials in source code. Use the server configuration file to manage connection secrets.