juice-shop
59 строк · 1.1 Кб
1/*
2* Copyright (c) 2014-2024 Bjoern Kimminich & the OWASP Juice Shop contributors.
3* SPDX-License-Identifier: MIT
4*/
5
6/* jslint node: true */
7
8import {
9Model,
10type InferAttributes,
11type InferCreationAttributes,
12DataTypes,
13type CreationOptional,
14type Sequelize
15} from 'sequelize'
16
17class Quantity extends Model<
18InferAttributes<Quantity>,
19InferCreationAttributes<Quantity>
20> {
21declare ProductId: number
22declare id: CreationOptional<number>
23declare quantity: number
24declare limitPerUser: number | null
25}
26
27const QuantityModelInit = (sequelize: Sequelize) => {
28Quantity.init(
29{
30ProductId: {
31type: DataTypes.INTEGER
32},
33id: {
34type: DataTypes.INTEGER,
35primaryKey: true,
36autoIncrement: true
37},
38quantity: {
39type: DataTypes.INTEGER,
40validate: {
41isInt: true
42}
43},
44limitPerUser: {
45type: DataTypes.INTEGER,
46validate: {
47isInt: true
48},
49defaultValue: null
50}
51},
52{
53tableName: 'Quantities',
54sequelize
55}
56)
57}
58
59export { Quantity as QuantityModel, QuantityModelInit }
60