Skip to content

Using bigserial / bigint in IdEntity #361

@thekevinbrown

Description

@thekevinbrown

Is your feature request related to a problem? Please describe.

We use bigserial in Postgres for many primary keys. Typescript has a built in bigint type, but I can't use it with IdEntity:

export class Credential implements IdEntity<Credential> {
	@PrimaryKey({ type: 'bigint' })
	id!: bigint;
}

gives

Type 'Credential' does not satisfy the constraint '{ id: string | number; }'.
  Types of property 'id' are incompatible.
    Type 'bigint' is not assignable to type 'string | number'.ts(2344)

Describe the solution you'd like

Maybe an approach like UuidEntity would work here? Maybe BigIntIdEntity? Or maybe it'd be simple enough to just have id in IdEntity defined as id: number | string | bigint;?

Describe alternatives you've considered

I'm relatively new to Mikro ORM, so I'm not sure what a good alternative would be. We need to be able to define the entity so the database handles it as well as not overflowing the number type if it gets large enough.

Additional context

None needed that I can tell.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions