enum type postgres query code example
Example 1: typeorm enum postgres
export enum UserRole {
ADMIN = "admin",
EDITOR = "editor",
GHOST = "ghost"
}
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column({
type: "enum",
enum: UserRole,
default: UserRole.GHOST
})
role: UserRole;
}
Example 2: psql view enum values
SELECT enum_range(NULL::myenum);