Skip to content

Conversation

@ericyoondotcom
Copy link
Contributor

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.

@mweibel mweibel merged commit 7f5417f into mweibel:master Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants