connect-session-sequelize icon indicating copy to clipboard operation
connect-session-sequelize copied to clipboard

Support table name being different than model key

Open ericyoondotcom opened this issue 1 year ago • 0 comments

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.

ericyoondotcom avatar Dec 03 '24 03:12 ericyoondotcom