Naming strategy
JSORM uses a configurable naming strategy to translate between TypeScript and the database.
Configuration
Section titled “Configuration”import { defineConfig } from "@jsorm/core";
export default defineConfig({ models: "src/models", databases: { main: { access: "server", provider: "postgres-node", options: { naming: { fields: "snake_case" }, }, }, },});Naming per database
Section titled “Naming per database”naming.fields |
JS property | DB column |
|---|---|---|
camelCase (default) |
emailVerified |
emailVerified |
snake_case |
emailVerified |
email_verified |
Table names are explicit — defined directly in defineModel().
Conventions
Section titled “Conventions”| Element | Rule | Examples |
|---|---|---|
| Models | Singular | User, Role, Post |
| Tables | Plural, explicit | defineModel("users", ...) |
| Fields | camelCase | createdAt, firstName |
| Relations | camelCase | role, createdBy |
| Databases | camelCase | main, cache, analytics |
Providers
Section titled “Providers”Providers follow the convention provider-{database}-{runtime}:
provider-sqlite-nodeprovider-pg-nodeprovider-indexeddbCompilers
Section titled “Compilers”SQL compilers are centralized in @jsorm/compiler (pg-node and sqlite-node delegate to it). IndexedDB keeps its own non-SQL compiler, internal to the provider.
