Open rajankumar77915 opened 6 months ago
Hey @rajankumar77915 We are using Postgres as Database
Subject:Add New Model to PostgreSQL Database
Dear @Mayank2808sharma ,
I hope you're doing well. I'm reaching out to request permission to add a new model to our PostgreSQL database. This addition is necessary to accommodate changes in our application's data structure and functionality.
The new model will be designed to [briefly describe the purpose or functionality of the new model, e.g., store user profiles, manage product inventory, etc.]. This will enhance the overall capabilities of our application and support future development efforts.
I will ensure that the new model is implemented following our database schema conventions and best practices to maintain data integrity and consistency.
Best regards, Abhishek
Hey @rajankumar77915 We are using Postgres as Database
then i will change according Postgres-sequelize way. like below const { DataTypes } = require('sequelize'); const sequelize = require('../config/database'); const TrainDetail = require('./TrainDetail');
const Station = sequelize.define('Station', { id: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true }, station_name: { type: DataTypes.STRING, allowNull: false }, reachTime: {//time when train will reach this station also it helps to ordering stations type: DataTypes.TIME, allowNull: false }, trainDetailId: { type: DataTypes.INTEGER, allowNull: false, references: { model: TrainDetail, key: 'id' } } });
Station.belongsTo(TrainDetail, {foreignKey: 'trainDetailId'});
Station.sync().then(() => { console.log("Station Model synced"); });
module.exports = Station;
can we talk on Discord rajankumar77915
i want to add TrainDetail schema and modify trainController.
above TrainDetail model will coupled with Train . inside Train Model i will add , TrainDetail:{ type:mongoose.Schema.Types.ObjectId, ref:"TrainDetail", }