connect-session-sequelize
connect-session-sequelize copied to clipboard
Support table name being different than model key
In Sequelize, the model key/class name can be different than the table name.
export default class SessionModel extends Model {
declare sid: string;
declare expires: Date;
declare data: string;
static initModel(sequelize: Sequelize) {
SessionModel.init({
sid: { type: DataTypes.STRING, primaryKey: true },
expires: { type: DataTypes.DATE },
data: { type: DataTypes.TEXT },
}, {
sequelize,
tableName: "session"
});
};
};
Here, the model name is SessionModel and the table name is session.
Currently, connect-session-sequelize assumes that the custom model name is the same as the custom table name. This PR adds support for using a different model key than table name.