tim/api/src/models/Client.ts
2023-12-31 17:16:23 +01:00

45 lines
757 B
TypeScript

import { DataTypes, Model } from 'sequelize'
import path from 'path'
import db from '../config/sequelize.config'
import User from './User'
class Instance extends Model {}
Instance.init(
{
_id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
allowNull: false,
unique: true
},
name: {
type: DataTypes.STRING,
allowNull: false
},
hourlyRate: {
type: DataTypes.INTEGER,
allowNull: true
},
contact: {
type: DataTypes.STRING,
allowNull: true
},
author_id: {
type: DataTypes.UUID,
allowNull: false,
references: {
model: User,
key: '_id'
}
}
},
{
sequelize: db,
tableName: path.basename(__filename).split('.')[0].toLowerCase()
}
)
export default Instance