Skip to content

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" },
},
},
},
});
Option Type Description
models string Relative path from the project root where models are located
databases Record<string, DatabaseConfig> Available databases
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.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().

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") },
},
},
});
.env
DATABASE_URL_SQLITE=./data/prod.db

If the value is not an env var name (e.g., ./data.db or :memory:), it is used directly without resolution.