juice-shop

Форк
0
/
quantity.ts 
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

8
import {
9
  Model,
10
  type InferAttributes,
11
  type InferCreationAttributes,
12
  DataTypes,
13
  type CreationOptional,
14
  type Sequelize
15
} from 'sequelize'
16

17
class Quantity extends Model<
18
InferAttributes<Quantity>,
19
InferCreationAttributes<Quantity>
20
> {
21
  declare ProductId: number
22
  declare id: CreationOptional<number>
23
  declare quantity: number
24
  declare limitPerUser: number | null
25
}
26

27
const QuantityModelInit = (sequelize: Sequelize) => {
28
  Quantity.init(
29
    {
30
      ProductId: {
31
        type: DataTypes.INTEGER
32
      },
33
      id: {
34
        type: DataTypes.INTEGER,
35
        primaryKey: true,
36
        autoIncrement: true
37
      },
38
      quantity: {
39
        type: DataTypes.INTEGER,
40
        validate: {
41
          isInt: true
42
        }
43
      },
44
      limitPerUser: {
45
        type: DataTypes.INTEGER,
46
        validate: {
47
          isInt: true
48
        },
49
        defaultValue: null
50
      }
51
    },
52
    {
53
      tableName: 'Quantities',
54
      sequelize
55
    }
56
  )
57
}
58

59
export { Quantity as QuantityModel, QuantityModelInit }
60

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.