I need to write a model with help of Sequelize, but I can't find an equivalent of Schema.Types.ObjectId, ref:"myModel" there. How I can implement this one? I'm new in this technology and in DataBases.
I'm trying to get an User Id from another model and put to this one when creating an instance in DB. It' ll help me to implement JWT token model.
const User = require('../').user
const {Sequelize} = require('sequelize')
module.exports = function (sequelize) {
const model = sequelize.define("TokenModel", {
user : {
type: //Id from another Model like in Mongoose
}
refreshToken: {
type: Sequelize.STRING,
},
}, {
timestamps: false
})
return model
}
Okey, I figured out:
modelA = belongsTo(modelB);
modelA = hasOne(modelB);
Solved this. Sorry for my bad knowledge of basics of SQL databases :)