Skip to content

Support enum for DB who don't support it #1414

Closed
@antoine-pous

Description

@antoine-pous

Currently SQLite doesn't have ENUM type, but TypeORM can use it's own validator before inserting a value into the DB and emit an error when the value is not in the enum.

enum MyEnum { 
    zero = 0; 
    one = 1;
}

@Entity()
export class Test {
    @Column({enum: MyEnum})
    myVar: number; // Must be 0 or 1
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions