const mongoose = require('mongoose'); const Schema = mongoose.Schema; const tokenSchema = new Schema({ userId: { type: Schema.Types.ObjectId, required: true, ref: 'user', }, email: { type: String, }, type: String, identifier: { type: String, }, token: { type: String, required: true, }, createdAt: { type: Date, required: true, default: Date.now, }, expiresAt: { type: Date, required: true, }, metadata: { type: Map, of: Schema.Types.Mixed, }, }); tokenSchema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 }); module.exports = tokenSchema;