UNPKG

undeexcepturi

Version:

TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.

40 lines (27 loc) 647 B
--- title: Using native BigInt PKs (MySQL and PostgreSQL) --- You can use `BigIntType` to support `bigint`s. By default it will represent the value as a `string`. ```typescript @Entity() export class Book { @PrimaryKey({ type: BigIntType }) id: string; } ``` If you want to use native `bigint` type, you will need to create new type based on the `BigIntType`: ```typescript export class NativeBigIntType extends BigIntType { convertToJSValue(value: any): any { if (!value) { return value; } return BigInt(value); } } @Entity() export class Book { @PrimaryKey({ type: NativeBigIntType }) id: bigint; } ```