Search code examples
databasepostgresqlnestjstypeorm

Are serial types like smallserial, serial, bigserial not available in TypeORM?


While creating an entity I wanted to use serial as my Column type, but typescript gives me error: Type '"smallserial"' is not assignable to type

I checked other serial types and got same error. Are these types not available? I am using Postgres database.

@PrimaryGeneratedColumn({ type: 'smallserial'})
id: number

Solution

  • From 8.1.4 Serial Types.

    The data types smallserial, serial and bigserial are not true types, but merely a notational convenience for creating unique identifier columns (similar to the AUTO_INCREMENT property supported by some other databases).

    The corresponding types are smallint, int, and bigint.

    For example, one uses an integer to reference a serial primary key. some_id integer not null references some_table(id).