Files
hounam-submit-form-backend/src/models/Identity.ts
2026-05-31 18:06:40 +03:30

123 lines
2.3 KiB
TypeScript

import { Model, DataTypes, Sequelize, Optional } from "sequelize";
export interface IdentityAttributes {
id: string;
applicantId: string;
firstName: string;
lastName: string;
fatherName: string;
nationalCode: string;
birthDate: Date;
birthPlace: string;
gender: string;
religion: string;
nationality: string;
profilePhotoId?: string;
createdAt?: Date;
updatedAt?: Date;
}
export interface IdentityCreationAttributes extends Optional<
IdentityAttributes,
"id" | "profilePhotoId"
> {}
export class Identity
extends Model<IdentityAttributes, IdentityCreationAttributes>
implements IdentityAttributes
{
public id!: string;
public applicantId!: string;
public firstName!: string;
public lastName!: string;
public fatherName!: string;
public nationalCode!: string;
public birthDate!: Date;
public birthPlace!: string;
public gender!: string;
public religion!: string;
public nationality!: string;
public profilePhotoId?: string;
public readonly createdAt!: Date;
public readonly updatedAt!: Date;
static initModel(sequelize: Sequelize): typeof Identity {
Identity.init(
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
applicantId: {
type: DataTypes.UUID,
allowNull: false,
},
firstName: {
type: DataTypes.STRING,
allowNull: false,
},
lastName: {
type: DataTypes.STRING,
allowNull: false,
},
fatherName: {
type: DataTypes.STRING,
},
nationalCode: {
type: DataTypes.STRING(10),
allowNull: false,
},
birthDate: {
type: DataTypes.DATEONLY,
},
birthPlace: {
type: DataTypes.STRING,
},
gender: {
type: DataTypes.ENUM("male", "female", "other"),
allowNull: true,
},
religion: {
type: DataTypes.STRING,
},
nationality: {
type: DataTypes.STRING,
},
profilePhotoId: {
type: DataTypes.UUID,
allowNull: true,
},
},
{
sequelize,
tableName: "identities",
timestamps: true,
},
);
return Identity;
}
}