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