Configuration
Manual configuration
Section titled “Manual configuration”If you prefer to configure manually, create jsorm.config.ts at the root:
import { defineConfig } from "@jsorm/core";
export default defineConfig({ models: "src/models", databases: { main: { access: "server", provider: "postgres-node", options: { naming: { fields: "snake_case" }, }, }, },});Options
Section titled “Options”defineConfig
Section titled “defineConfig”| Option | Type | Description |
|---|---|---|
models |
string |
Relative path from the project root where models are located |
databases |
Record<string, DatabaseConfig> |
Available databases |
DatabaseConfig
Section titled “DatabaseConfig”| Option | Type | Description |
|---|---|---|
access |
"server" | "client" |
Model available on server or client |
provider |
string |
Provider name (e.g., pg-node, sqlite-node, indexeddb) |
options |
Record<string, any> |
Provider-specific options |
options.naming.fields |
"snake_case" | "camelCase" |
Naming convention for columns |
Naming
Section titled “Naming”naming.fields |
JS property | DB column |
|---|---|---|
| (not set) | emailVerified |
emailVerified |
snake_case |
emailVerified |
email_verified |
camelCase |
emailVerified |
emailVerified |
If naming is not configured, DB columns will use the exact same name as the JS property (no transformation applied). For example, a property named emailVerified maps directly to the column emailVerified.
Table names are explicit — defined directly in defineModel().
Environment variables
Section titled “Environment variables”Use env() from @jsorm/core to mark values as env vars:
import { defineConfig, env } from "@jsorm/core";
export default defineConfig({ databases: { main: { provider: "sqlite-node", options: { database: env("DATABASE_URL_SQLITE") }, }, },});DATABASE_URL_SQLITE=./data/prod.dbIf the value is not an env var name (e.g., ./data.db or :memory:), it is used directly without resolution.
