How to use the sequelize-typescript.DataType.ENUM function in sequelize-typescript

To help you get started, we’ve selected a few sequelize-typescript examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BMalaichik / nestjs-starter-kit / packages / backend / src / modules / db / entities / permission.entity.ts View on Github external
USER_MANAGEMENT_ADD         = "user_management_add",
    USER_MANAGEMENT_UPDATE      = "user_management_update",
    USER_MANAGEMENT_DELETE      = "user_management_delete",
}

const permissions: string[] = _.values(PermissionName);

@Table({
    tableName: "permission",
})
export class Permission extends Model {

    public id: number;

    @Column({
        type: DataType.ENUM(permissions),
        allowNull: false,
        validate: {
            isIn: [permissions],
        },
        unique: true,
    })
    name: PermissionName;

    @Column({
        type: DataType.STRING,
    })
    description: string;
}
github oughtinc / mosaic / server / lib / models / instructions.ts View on Github external
import Experiment from "./experiment";

export const InstructionTypes = [
  "root",
  "honestOracle",
  "maliciousOracle",
  "returningRoot",
  "returningHonestOracle",
  "returningMaliciousOracle",
  "lazyPointerUnlock",
];

@Table
export default class Instructions extends Model {
  @AllowNull(false)
  @Column(DataType.ENUM({ values: InstructionTypes }))
  public type: string;

  @AllowNull(false)
  @Column(DataType.TEXT)
  public value: string;

  @ForeignKey(() => Experiment)
  @Column(DataType.UUID)
  public experimentId: string;

  @BelongsTo(() => Experiment)
  public experiment: Experiment;
}
github BMalaichik / nestjs-starter-kit / packages / backend / src / modules / db / entities / file.entity.ts View on Github external
public id: number;

    public static PUBLIC_ATTRIBUTES: (keyof File)[] = [
        "type",
        "name",
        "title",
    ];

    @Column({
        type: DataType.DATE,
        allowNull: false,
    })
    uploadDate: Date;

    @Column({
        type: DataType.ENUM(types),
        allowNull: false,
        validate: {
            isIn: [types],
        },
    })
    type: FileType;

    @Column({  allowNull: false })
    title: string;

    @Column({ type: DataType.STRING })
    description: string;

    @Column({  allowNull: false })
    key: string;
github BMalaichik / nestjs-starter-kit / packages / backend / src / modules / db / entities / user.entity.ts View on Github external
@Table({
    indexes: [
        {
            unique: true,
            fields: ["contactId"],
        },
    ],
    tableName: "user",
})
export class User extends Model {

    public id: number;
    public static PUBLIC_ATTRIBUTES: (keyof User)[] = ["role", "isActive"];

    @Column({
        type: DataType.ENUM(roles),
        allowNull: false,
        validate: {
            isIn: [roles],
        },
    })
    role: UserRole;

    @Column({
        type: DataType.BOOLEAN,
    })
    isActive?: boolean;

    @Column({
        type: DataType.STRING,
        allowNull: false,
    })
github BMalaichik / nestjs-starter-kit / packages / backend / src / modules / db / entities / role.entity.ts View on Github external
}

export type RoleWildcard = "*";
export const RoleWildcard = "*";

const roles: string[] = _.values(RoleName);

@Table({
    tableName: "role",
})
export class Role extends Model {

    public id: number;

    @Column({
        type: DataType.ENUM(roles),
        allowNull: false,
        unique: true,
        validate: {
            isIn: [roles],
        },
    })
    name: RoleName;

    @Column({
        type: DataType.STRING,
    })
    description: string;
}
github thx / rap2-delos / src / models / bo / property.ts View on Github external
export default class Property extends Model {
  public static TYPES = TYPES
  public static SCOPES = SCOPES

  @AutoIncrement
  @PrimaryKey
  @Column
  id: number

  static attributes: any


  @AllowNull(false)
  @Default(SCOPES.RESPONSE)
  @Column({
    type: DataType.ENUM(SCOPES.REQUEST, SCOPES.RESPONSE),
    comment: 'property owner',
  })
  scope: string

  @AllowNull(false)
  @Column({
    type: DataType.ENUM(TYPES.STRING, TYPES.NUMBER, TYPES.BOOLEAN, TYPES.OBJECT, TYPES.ARRAY, TYPES.FUNCTION, TYPES.REGEXP, TYPES.Null),
    comment: 'property type',
  })
  /** Data Type */
  type: string

  @AllowNull(false)
  @Default(2)
  @Column
  /** request params type (position) */
github thx / rap2-delos / src / models / bo / logger.ts View on Github external
CREATE = 'create', UPDATE = 'update', DELETE = 'delete',
  LOCK = 'lock', UNLOCK = 'unlock', JOIN = 'join', EXIT = 'exit',
}

@Table({ paranoid: true, freezeTableName: false, timestamps: true })
export default class Logger extends Model {
  public static TYPES = types

  @AutoIncrement
  @PrimaryKey
  @Column
  id: number

  @AllowNull(false)
  @Column({
    type: DataType.ENUM(types.CREATE, types.UPDATE, types.DELETE, types.LOCK, types.UNLOCK, types.JOIN, types.EXIT),
    comment: 'operation type',
  })
  type: string

  @ForeignKey(() => User)
  @Column
  creatorId: number

  @AllowNull(false)
  @ForeignKey(() => User)
  @Column
  userId: number

  @ForeignKey(() => Organization)
  @Column
  organizationId: number
github thx / rap2-delos / src / models / bo / property.ts View on Github external
id: number

  static attributes: any


  @AllowNull(false)
  @Default(SCOPES.RESPONSE)
  @Column({
    type: DataType.ENUM(SCOPES.REQUEST, SCOPES.RESPONSE),
    comment: 'property owner',
  })
  scope: string

  @AllowNull(false)
  @Column({
    type: DataType.ENUM(TYPES.STRING, TYPES.NUMBER, TYPES.BOOLEAN, TYPES.OBJECT, TYPES.ARRAY, TYPES.FUNCTION, TYPES.REGEXP, TYPES.Null),
    comment: 'property type',
  })
  /** Data Type */
  type: string

  @AllowNull(false)
  @Default(2)
  @Column
  /** request params type (position) */
  pos: number

  @AllowNull(false)
  @Column(DataType.STRING(256))
  name: string

  @Column({ type: DataType.STRING(128), comment: 'property generation rules' })