import DB from "../database";
import { ModelDataBase } from "@hibas123/safe_mongo/lib/model";
import { ObjectID } from "mongodb";
import { v4 } from "uuid";

export interface IRefreshToken extends ModelDataBase {
   token: string;
   user: ObjectID;
   client: ObjectID;
   permissions: ObjectID[];
   validTill: Date;
   valid: boolean;
}

const RefreshToken = DB.addModel<IRefreshToken>({
   name: "refresh_token",
   versions: [
      {
         migration: () => {},
         schema: {
            token: { type: String },
            user: { type: ObjectID },
            client: { type: ObjectID },
            permissions: { type: Array },
            validTill: { type: Date },
            valid: { type: Boolean },
         },
      },
   ],
});

export default RefreshToken;
