Naming Strategy
A naming strategy turns your TypeScript names into database names, so code stays camelCase while the schema stays snake_case. Set it on the pool your app and uql.config.ts use:
import { SnakeCaseNamingStrategy } from 'uql-orm';import { PgQuerierPool } from 'uql-orm/postgres';
export const pool = new PgQuerierPool( { host: 'localhost', database: 'my_db' }, { namingStrategy: new SnakeCaseNamingStrategy() },);The entity UserAccount then maps to the table user_account, and the fields createdAt and authorId to the columns created_at and author_id. Without a strategy, or with DefaultNamingStrategy, names are used as written.
The strategy applies to queries and migrations alike. Set it before you scaffold entities from an existing database, so the generated classes use the same mapping.
A name you write yourself skips the strategy: @Entity({ name: 'Users' }), a schema, and a @Field({ name }) that differs from its property are used as written.
Custom strategy
Section titled “Custom strategy”Implement NamingStrategy, or extend DefaultNamingStrategy and override what you need:
import { DefaultNamingStrategy } from 'uql-orm';
export class PrefixedNamingStrategy extends DefaultNamingStrategy { override tableName(entityName: string): string { return `tbl_${super.tableName(entityName)}`; }}