Skip to content

Commit e49ebb8

Browse files
committed
add expiration time
1 parent ab77ba5 commit e49ebb8

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

‎back/src/dals/room/room.context.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ import { RoomInfo } from 'dals';
33

44
const roomSchema = new Schema({
55
room: Schema.Types.String,
6-
content: Schema.Types.String
6+
content: Schema.Types.String,
7+
expireAt: {
8+
type: Schema.Types.Date,
9+
default: Date.now,
10+
index: {
11+
expires: '2d',
12+
},
13+
},
714
});
815

9-
export const RoomContext = model<RoomInfo & Document>(
10-
'RoomInfo',
11-
roomSchema
12-
);
16+
export const RoomContext = model<RoomInfo & Document>('RoomInfo', roomSchema);

‎back/src/dals/session/session.context.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ const userSessionSchema = new Schema({
55
room: Schema.Types.String,
66
trainerToken: Schema.Types.String,
77
isTrainer: Schema.Types.Boolean,
8-
connectionId: Schema.Types.String
8+
connectionId: Schema.Types.String,
9+
expireAt: {
10+
type: Schema.Types.Date,
11+
default: Date.now,
12+
index: {
13+
expires: '2d',
14+
},
15+
},
916
});
1017

1118
export const UserSessionContext = model<UserSession & Document>(

0 commit comments

Comments
 (0)