-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbook.model.ts
More file actions
35 lines (32 loc) · 827 Bytes
/
book.model.ts
File metadata and controls
35 lines (32 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { DataTypes, Model } from 'sequelize';
import { sequelize } from './sequelize-setup';
class Book extends Model {
public id!: number;
public title!: string;
public author!: string;
public publisher!: string;
public publishDate!: Date;
public price!: number;
public categoryId!: number;
}
Book.init(
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
title: DataTypes.STRING,
author: DataTypes.STRING,
publisher: DataTypes.STRING,
publishDate: DataTypes.DATE,
price: DataTypes.FLOAT,
categoryId: DataTypes.INTEGER,
},
{
tableName: 'books',
sequelize,
underscored: true,
}
);
export { Book };