first commit
This commit is contained in:
119
src/models/Identity.ts
Normal file
119
src/models/Identity.ts
Normal file
@@ -0,0 +1,119 @@
|
||||
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.STRING
|
||||
},
|
||||
|
||||
religion: {
|
||||
type: DataTypes.STRING
|
||||
},
|
||||
|
||||
nationality: {
|
||||
type: DataTypes.STRING
|
||||
},
|
||||
|
||||
profilePhotoId: {
|
||||
type: DataTypes.UUID,
|
||||
allowNull: true
|
||||
}
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
tableName: "identities",
|
||||
timestamps: true
|
||||
}
|
||||
);
|
||||
|
||||
return Identity;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user