Browse Source

refactor: rename Session primary key to simply be _id

Kristian Vos 2 months ago
parent
commit
44f2fb9b2e

+ 1 - 1
backend/src/modules/DataModule/migrations/1725660137-create-sessions-table.ts

@@ -5,7 +5,7 @@ export const up = async ({
 	context: sequelize
 	context: sequelize
 }: MigrationParams<Sequelize>) => {
 }: MigrationParams<Sequelize>) => {
 	await sequelize.getQueryInterface().createTable("sessions", {
 	await sequelize.getQueryInterface().createTable("sessions", {
-		sessionId: {
+		_id: {
 			type: DataTypes.OBJECTID,
 			type: DataTypes.OBJECTID,
 			allowNull: false,
 			allowNull: false,
 			primaryKey: true
 			primaryKey: true

+ 2 - 2
backend/src/modules/DataModule/models/Session.ts

@@ -18,7 +18,7 @@ export class Session extends Model<
 	InferAttributes<Session>,
 	InferAttributes<Session>,
 	InferCreationAttributes<Session>
 	InferCreationAttributes<Session>
 > {
 > {
-	declare sessionId: ObjectIdType;
+	declare _id: ObjectIdType;
 
 
 	declare userId: ForeignKey<User["_id"]>;
 	declare userId: ForeignKey<User["_id"]>;
 
 
@@ -40,7 +40,7 @@ export class Session extends Model<
 }
 }
 
 
 export const schema = {
 export const schema = {
-	sessionId: {
+	_id: {
 		type: DataTypes.OBJECTID,
 		type: DataTypes.OBJECTID,
 		allowNull: false,
 		allowNull: false,
 		primaryKey: true
 		primaryKey: true

+ 2 - 2
backend/src/modules/WebSocketModule.ts

@@ -140,7 +140,7 @@ export class WebSocketModule extends BaseModule {
 				},
 				},
 				{
 				{
 					where: {
 					where: {
-						sessionId
+						_id: sessionId
 					}
 					}
 				}
 				}
 			);
 			);
@@ -263,7 +263,7 @@ export class WebSocketModule extends BaseModule {
 					},
 					},
 					{
 					{
 						where: {
 						where: {
-							sessionId: socket.getSessionId()
+							_id: socket.getSessionId()
 						}
 						}
 					}
 					}
 				);
 				);