import { model, Schema } from "mongoose"; const companySchema = new Schema( { name: { type: String, required: true, unique: true, }, }, { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true }, } ); companySchema.virtual("users", { ref: "User", localField: "_id", foreignField: "companyId", }); companySchema.virtual("scheduledSessions", { ref: "Scheduled_Session", localField: "_id", foreignField: "companyId", }); companySchema.virtual("builds", { ref: "Build", localField: "_id", foreignField: "companyId", }); const Company = model("Company", companySchema); export default Company;