Norm class
The value returned by the bundle (and the global Norm): factories, type constructors, and the entry point Norm.new.
Auto-generated
This page is generated from the source annotations by scripts/gen-api.mjs. Edit the LuaCATS doc comments in the Norm sources, not here.
Public API surface of Norm (the value returned by the bundle / global Norm).
| Member | Returns | Description |
|---|---|---|
Adapter | — | Base adapter class — extend (or duck-type) for custom adapters. |
adapters | — | Built-in adapters. |
class | — | The (separately loaded) class system. |
dialect | — | Built-in SQL dialects. |
json | — | JSON providers (nanos/rapidjson/raw/detect/define) for json columns. |
new | NormOrm | Create a new ORM instance from an adapter (and optionally a promise provider). |
Orm | — | The ORM root class. |
promise | — | Promise providers + builders. |
types | — | Column type factories. |
Adapter field
NormAdapterBase adapter class — extend (or duck-type) for custom adapters.
adapters field
NormAdaptersBuilt-in adapters.
class field
LightClassFactoryThe (separately loaded) class system.
dialect field
NormDialectsBuilt-in SQL dialects.
json field
NormJsonLibJSON providers (nanos/rapidjson/raw/detect/define) for json columns.
new function
function Norm.new(options: NormOptions)
-> NormOrmCreate a new ORM instance from an adapter (and optionally a promise provider). This is the entry point: build it once, then :define your models.
local db = Norm.new({
adapter = Norm.adapters.nanos.new({ engine = DatabaseEngine.SQLite, connection = "./game.db" }),
-- promise = Norm.promise.nanos(Promise), -- optional; auto-detected on nanos
log = true,
})
local User = db:define("users", { id = Norm.types.id(), name = Norm.types.string() })
db:sync():await()Orm field
NormOrmThe ORM root class.
promise field
NormPromiseLibPromise providers + builders.
types field
NormTypesColumn type factories.