// app/models/web-token.ts // Copyright (C) 2026 Robert Colbert // All Rights Reserved import { Schema, Types, model } from "mongoose"; import { IUser } from "./user.js"; import { DtpLog } from "../lib/log.js"; const log = new DtpLog({ name: "WebTokenModel", slug: "webToken", }); export interface IWebToken { _id: Types.ObjectId; created: Date; expires: Date; user: IUser | Types.ObjectId; token: string; } export const WebTokenSchema = new Schema({ created: { type: Date, required: true, index: 1 }, expires: { type: Date, required: true, index: -1 }, user: { type: Schema.Types.ObjectId, required: true, ref: "User" }, token: { type: String, required: true }, }); export const WebToken = model("WebToken", WebTokenSchema); export default WebToken; (async () => { log.info("Syncing indexes..."); await WebToken.syncIndexes(); })();