From 4f25b10f59e87bea9f59c1c4b2e3653ab730d1b3 Mon Sep 17 00:00:00 2001 From: sevelinCA Date: Tue, 21 May 2024 18:07:49 +0200 Subject: [PATCH] adding two missing attributes --- src/database/config/db.config.ts | 4 ++++ .../migrations/20240520101722-create-user.js | 4 ++-- .../migrations/20240520143337-create-rating.js | 2 +- src/database/models/product.ts | 12 ++++++------ src/index.ts | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/database/config/db.config.ts b/src/database/config/db.config.ts index 009dc99..5171bba 100644 --- a/src/database/config/db.config.ts +++ b/src/database/config/db.config.ts @@ -10,6 +10,10 @@ const MODE:any = process.env.MODE || 'development' const connectSequelize:Sequelize = new Sequelize(config[`${MODE}`].url,{ dialect: config[`${MODE}`].dialect, dialectOptions: { + ssl: { + require: true, + rejectUnauthorized: true + } } }) diff --git a/src/database/migrations/20240520101722-create-user.js b/src/database/migrations/20240520101722-create-user.js index 922d745..fd58e0c 100644 --- a/src/database/migrations/20240520101722-create-user.js +++ b/src/database/migrations/20240520101722-create-user.js @@ -26,10 +26,10 @@ module.exports = { defaultValue: 'active' }, wishlistId:{ - type: Sequelize.INTEGER, + type: Sequelize.STRING, }, cartId: { - type: Sequelize.INTEGER + type: Sequelize.STRING }, role: { type: Sequelize.STRING, diff --git a/src/database/migrations/20240520143337-create-rating.js b/src/database/migrations/20240520143337-create-rating.js index 65a1350..5cf138a 100644 --- a/src/database/migrations/20240520143337-create-rating.js +++ b/src/database/migrations/20240520143337-create-rating.js @@ -13,7 +13,7 @@ module.exports = { type: Sequelize.INTEGER }, userId: { - type: Sequelize.INTEGER, + type: Sequelize.STRING, references:{ model: 'Users', key: 'userId' diff --git a/src/database/models/product.ts b/src/database/models/product.ts index f2ec524..09ae554 100644 --- a/src/database/models/product.ts +++ b/src/database/models/product.ts @@ -4,14 +4,15 @@ import connectSequelize from "../config/db.config"; import { ftruncate } from "fs"; class Product extends Model { - public productId?: number + public productId?: string + public vendorId: any public name!: string public description!: string public image!: string public discount!: number public price!: string public quantity!: number - public vendorId: any + public category!: string static associate(models: any) { Product.hasMany(models.Wishlist,{ foreignKey: 'productId', @@ -22,20 +23,19 @@ import { ftruncate } from "fs"; as: 'wishlists' }) - Product.belongsTo(models.Vendor,{ - foreignKey: 'vendorId', - as: 'vendor' - }) + } } Product.init({ productId: {type:DataTypes.UUID,primaryKey: true,defaultValue: DataTypes.UUIDV4}, + vendlorId: {type:DataTypes.STRING,primaryKey: true,defaultValue: DataTypes.UUIDV4}, name: {type:DataTypes.STRING,allowNull: false}, description: {type:DataTypes.STRING,allowNull: false}, image: {type:DataTypes.STRING,allowNull: false}, discount: {type:DataTypes.INTEGER,allowNull: false}, price: {type:DataTypes.INTEGER,allowNull: false}, quantity: {type:DataTypes.INTEGER,allowNull: true}, + category: {type:DataTypes.STRING,allowNull: true}, }, { sequelize: connectSequelize, diff --git a/src/index.ts b/src/index.ts index 4dc28a3..4f5f9cb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,7 @@ import express from "express"; import dotenv from "dotenv"; dotenv.config(); const PORT = process.env.PORT; -import { userss } from "./database/seeders/users"; +