helloya20's picture
Upload 2345 files
f0743f4 verified
import { Schema } from 'mongoose';
import { IToken } from '~/types';
const tokenSchema: Schema<IToken> = new Schema({
userId: {
type: Schema.Types.ObjectId,
required: true,
ref: 'user',
},
email: {
type: String,
},
type: {
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 });
export default tokenSchema;