Skip to content

Support table name being different than model key #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2025

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