Skip to content

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).

🔗 Source: src/init.lua

MemberReturnsDescription
AdapterBase adapter class — extend (or duck-type) for custom adapters.
adaptersBuilt-in adapters.
classThe (separately loaded) class system.
dialectBuilt-in SQL dialects.
jsonJSON providers (nanos/rapidjson/raw/detect/define) for json columns.
newNormOrmCreate a new ORM instance from an adapter (and optionally a promise provider).
OrmThe ORM root class.
promisePromise providers + builders.
typesColumn type factories.

Adapter field

lua
NormAdapter

Base adapter class — extend (or duck-type) for custom adapters.

adapters field

lua
NormAdapters

Built-in adapters.

class field

lua
LightClassFactory

The (separately loaded) class system.

dialect field

lua
NormDialects

Built-in SQL dialects.

json field

lua
NormJsonLib

JSON providers (nanos/rapidjson/raw/detect/define) for json columns.

new function

lua
function Norm.new(options: NormOptions)
  -> NormOrm

Create a new ORM instance from an adapter (and optionally a promise provider). This is the entry point: build it once, then :define your models.

lua
    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

lua
NormOrm

The ORM root class.

promise field

lua
NormPromiseLib

Promise providers + builders.

types field

lua
NormTypes

Column type factories.