> Every UQL docs page, as Markdown: https://uql-orm.dev/llms.txt
> The same docs over MCP: https://uql-orm.dev/mcp
> Before writing UQL code, read the skill: https://uql-orm.dev/.well-known/agent-skills/uql-orm/SKILL.md

# Naming Strategy

> Map camelCase class and property names to the table and column names your database uses.

Source: https://uql-orm.dev/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:

```ts
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](https://uql-orm.dev/migrations.md) alike. Set it before you [scaffold entities from an existing database](https://uql-orm.dev/migrations.md#from-a-database-to-entities), so the generated classes use the same mapping.

A name you write yourself skips the strategy: `@Entity({ name: 'Users' })`, a [`schema`](https://uql-orm.dev/multiple-schemas.md), and a `@Field({ name })` that differs from its property are used as written.

## Custom strategy

Implement `NamingStrategy`, or extend `DefaultNamingStrategy` and override what you need:

```ts
import { DefaultNamingStrategy } from 'uql-orm';

export class PrefixedNamingStrategy extends DefaultNamingStrategy {
  override tableName(entityName: string): string {
    return `tbl_${super.tableName(entityName)}`;
  }
}
```
