Documentation Index
Fetch the complete documentation index at: https://docs.sure-developer.com/llms.txt
Use this file to discover all available pages before exploring further.
DB
Thedb module is available on the server. It builds small model objects around oxmysql async exports and adds console commands for pushing Lua schemas to SQL tables or pulling SQL tables back into Lua schema files.
Create a model
Logical model name. If
tableName is not supplied, this is also the SQL table name.Optional SQL table override.
Optional schema field map or ordered field array used by the console
push command.Query helpers
update and delete require a non-empty where table. sure_lib returns nil and logs an error instead of running broad updates or deletes without a filter.Schema files
Create schema files underdb/<schemaName>.lua in the resource that owns the database models.
db/users.lua
Field types
| Lua type | SQL type |
|---|---|
integer | INT |
bigint | BIGINT |
float | FLOAT |
double | DOUBLE |
string | VARCHAR(length or 255) |
text | TEXT |
boolean | TINYINT(1) |
timestamp | TIMESTAMP |
json | JSON |
length, nullable = false, default, autoIncrement = true, unique = true, and primaryKey = true.
Console commands
The command name is prefixed with the current resource name. Forsure_lib, the command is sure_lib:db.
- Push
- Pull
db/users.lua and runs CREATE TABLE IF NOT EXISTS.DB console commands are console-only. If a player source tries to run them, sure_lib logs
[sure_lib][db] db commands are console-only.