A nanos world package that bundles Norm — a dependency-free Lua ORM — and exports it server-side. The ORM is vendored as a git submodule and is fully self-contained (light-class is embedded), so there is nothing else to install.
Norm talks to a database, so it is server-side only. This package lives in
Server/and exports a globalNorm.
Full documentation: https://justgodwork.github.io/norm-docs/
git submodule update --init --recursive # pull the vendored NormServer/Index.lua loads the bundle and exports it:
local Norm = require 'vendor/norm/dist/norm.lua' -- embeds light-class, exposes `Norm`
Package.Export('Norm', Norm) -- available to other packages' server scriptsAdd nmrp-norm to your package's packages_requirements, and Norm is global:
local db = Norm.new({
adapter = Norm.adapters.nanos.new({ engine = DatabaseEngine.SQLite, connection = "./database.db" }),
})
local User = db:define("users", {
id = Norm.types.id(),
name = Norm.types.string({ length = 64, nullable = false }),
})
coroutine.wrap(function()
db:sync():await()
local u = User:create({ name = "John" }):await()
Console.Log("user #%d", u.id)
end)()The full ORM API is documented in the core README:
Server/vendor/norm/README.md — models, relations,
the query builder, transactions, migrations, hooks, soft deletes, and the rest.
These are handled for you by the nanos adapter / auto-detection:
- Adapter —
Norm.adapters.nanos.new({ engine, connection, pool_size? })opens a pooledDatabase(engine, connection_string, pool_size)and logs the connection. - Promises —
nmrp-promiseis optional. If it's loaded (globalPromise), Norm returns nanos promises; otherwise it uses its built-in one.promise:await()works the same either way — prefer it for code that's identical across providers. - Atomic insert ids — on SQLite (and MariaDB ≥ 10.5, auto-detected via
SELECT VERSION()) Norm fetches new ids viaINSERT … RETURNING, which is pool-safe. Real MySQL has noRETURNING, so it falls back to a best-effortLAST_INSERT_ID(). - JSON columns — automatically use the nanos global
JSON(stringify/parse). - Transactions — nanos'
Databaseexposes no transaction API, sodb:transaction(...)throws there. Checkdb:supports_transactions()first.
The bundle is vendored so the package runs out of the box. After editing the core
sources (Server/vendor/norm/src/), rebuild it:
cd Server/vendor/norm && lua build.lua # regenerates dist/norm.lua + dist/norm.min.luaMIT © 2026 JustGodWork. Vendored submodules (light-class, Norm) keep their own licenses.