Skip to content

Commit

Permalink
adding two missing attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
sevelinCa committed May 21, 2024
1 parent 8c950d7 commit 4f25b10
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/database/config/db.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

})
Expand Down
4 changes: 2 additions & 2 deletions src/database/migrations/20240520101722-create-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/database/migrations/20240520143337-create-rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
type: Sequelize.INTEGER
},
userId: {
type: Sequelize.INTEGER,
type: Sequelize.STRING,
references:{
model: 'Users',
key: 'userId'
Expand Down
12 changes: 6 additions & 6 deletions src/database/models/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";




Expand Down

0 comments on commit 4f25b10

Please sign in to comment.