Skip to main content
Version: 3.6

Using native BigInt PKs (MySQL and PostgreSQL)

You can use BigIntType to support bigints. By default it will represent the value as a string.

@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:

export class NativeBigIntType extends BigIntType {

convertToJSValue(value: any): any {
return BigInt(value);
}

}

@Entity()
export class Book {

@PrimaryKey({ type: NativeBigIntType })
id: bigint;

}