Answer the question
In order to leave comments, you need to log in
Am I using the model key reference in Sequelize correctly?
Can you please tell me if I correctly rewrote the mongoose code to sequileze, namely the user key, which should be a link to the user id?
Now everything works fine, but I want to be sure that in the future there will be no problems using this
MONGOOSE approach
const TokenSchema = new Schema({
user: {type: Schema.Types.ObjectId, ref: 'User'},
refreshToken: {type: String, required: true},
})
const Token = sequelize.define('token', {
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
user: {
type: DataTypes.INTEGER,
references: { model: User, key: 'id' },
},
refreshToken: { type: DataTypes.STRING, allowNull: false },
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question