update user refactor
This commit is contained in:
1 parent
88bb8ef2d3
commit
cb5b8e0673
16 files changed
+293
-80
No files matched your search
Executable
+30
@@ -0,0 +1,30 @@
|
||||
import { Schema, model, type Types } from "mongoose";
|
||||
import type { Invite } from "@/types/invite.js";
|
||||
|
||||
type InviteDocumentBase = Omit<Invite, "id" | "teamId" | "createdAt" | "updatedAt" | "expiry"> & {
|
||||
teamId: Types.ObjectId;
|
||||
expiry: Date;
|
||||
};
|
||||
|
||||
interface InviteDocument extends InviteDocumentBase {
|
||||
_id: Types.ObjectId;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
const InviteSchema = new Schema<InviteDocument>(
|
||||
{
|
||||
email: { type: String, required: true, unique: true },
|
||||
teamId: { type: Schema.Types.ObjectId, ref: "Team", immutable: true, required: true },
|
||||
role: { type: [String], required: true, default: ["user"] },
|
||||
token: { type: String, required: true },
|
||||
expiry: { type: Date, default: Date.now, expires: 3600 },
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
const InviteModel = model<InviteDocument>("Invite", InviteSchema);
|
||||
|
||||
export type { InviteDocument };
|
||||
export { InviteModel };
|
||||
export default InviteModel;
|
||||
Reference in new issue
Block a user