other
This commit is contained in:
40
backend/models/Invitation.model.js
Normal file
40
backend/models/Invitation.model.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const InvitationSchema = new mongoose.Schema({
|
||||
code: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true,
|
||||
},
|
||||
createdBy: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'Staffs',
|
||||
required: true,
|
||||
},
|
||||
isUsed: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
usedBy: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'Vendor',
|
||||
default: null,
|
||||
},
|
||||
expiresAt: {
|
||||
type: Date,
|
||||
required: true,
|
||||
},
|
||||
createdAt: {
|
||||
type: Date,
|
||||
default: Date.now,
|
||||
},
|
||||
usedAt: {
|
||||
type: Date,
|
||||
default: null,
|
||||
}
|
||||
});
|
||||
|
||||
InvitationSchema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
|
||||
InvitationSchema.index({ code: 1 });
|
||||
|
||||
export default mongoose.model("Invitation", InvitationSchema);
|
||||
Reference in New Issue
Block a user