CampFirePlay/models/inventory.model.js
Degradin 7e6980207f v5.3
Menu rework
Inventory system
Shop
2025-01-10 19:09:05 +03:00

62 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const { DataTypes } = require('sequelize');
const sequelize = require('../db');
const { faker } = require('@faker-js/faker');
const Inventory = sequelize.define('inventory', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
telegram_id: {
type: DataTypes.BIGINT, // Используем другой внешний ключ
references: {
model: 'characters', // Указываем правильное имя модели
key: 'telegram_id', // Внешний ключ указывает на telegram_id в модели Character
},
},
name: {
type: DataTypes.STRING,
allowNull: false,
},
text_id: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: faker.string.uuid()
},
description: {
type: DataTypes.TEXT,
allowNull: false,
},
effectData: {
type: DataTypes.JSON,
allowNull: true
},
price: {
type: DataTypes.INTEGER,
allowNull: false,
},
rarity: {
type: DataTypes.INTEGER,
allowNull: false,
},
type: {
type: DataTypes.STRING, // Тип предмета (например, "инструмент", "ресурс")
allowNull: false,
},
duration: {
type: DataTypes.INTEGER,
allowNull: true
}, // Длительность эффекта в секундах
canBeEquipped: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
equipped: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
});
module.exports = Inventory;