Spaces:
Sleeping
Sleeping
File size: 641 Bytes
da819ac |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
const mongoose = require('mongoose');
const accessSessionSchema = new mongoose.Schema({
email: { type: String, index: true },
role: { type: String, enum: ['student', 'instructor', 'admin', 'visitor'], index: true },
startAt: { type: Date, default: Date.now, index: true },
lastSeen: { type: Date, default: Date.now, index: true },
userAgent: { type: String },
ip: { type: String },
path: { type: String }
}, { timestamps: true });
// Compound index for querying active sessions by email + startAt
accessSessionSchema.index({ email: 1, startAt: -1 });
module.exports = mongoose.model('AccessSession', accessSessionSchema);
|