Skip to main content

TypeORM Extensions

Type-safe extensions for the TypeORM QueryBuilder: typed queries, pagination, SQL helpers

Typed queries

Select, join, filter, group and order with property callbacks checked against your entities: a renamed column is a compile error, not a failed query.

Pagination

A page with its total and hasMore in one call, or keyset pages with an opaque cursor, on entities and on raw rows.

SQL helpers and columns

tableHelper quotes the raw SQL you still write, a guard catches reserved words, and @CalculatedColumn / @GeneratedColumn describe values TypeORM never writes.

import 'typeorm-extensions';

const { list, total, hasMore } = await dataSource
.getRepository(UserEntity)
.createQueryBuilder('user')
.leftJoinTyped(user => user.images, 'images')
.whereTyped(user => user.createdAt, '>', since)
.andWhereTyped(user => user.metadata.role, '=', 'admin')
.orderByTyped(user => user.images.url, 'ASC', 'NULLS LAST')
.getManyWithTotals({ page: 1, pageSize: 20 });