40 lines
687 B
TypeScript
40 lines
687 B
TypeScript
import { model, Schema } from "mongoose";
|
|
|
|
const buildSchema = new Schema(
|
|
{
|
|
companyId: {
|
|
type: Schema.Types.ObjectId,
|
|
required: true,
|
|
},
|
|
name: {
|
|
type: String,
|
|
required: true,
|
|
unique: true,
|
|
},
|
|
build: {
|
|
type: String,
|
|
required: true,
|
|
unique: true,
|
|
},
|
|
sessionLimit: {
|
|
type: Number,
|
|
required: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
toJSON: { virtuals: true },
|
|
toObject: { virtuals: true },
|
|
}
|
|
);
|
|
|
|
buildSchema.virtual("scheduledSessions", {
|
|
ref: "Scheduled_Session",
|
|
localField: "_id",
|
|
foreignField: "buildId",
|
|
});
|
|
|
|
const Build = model("Build", buildSchema);
|
|
|
|
export default Build;
|