import mongoose from "mongoose"; const { Schema } = mongoose; const gcodeFileSchema = new mongoose.Schema({ name: { required: true, type: String }, gcodeFileName: { required: false, type: String }, gcodeFileInfo: { required: true, type: Object }, size: { type: Number, required: false }, filament: { type: Schema.Types.ObjectId, ref: "Filament", required: true }, parts: [{ type: Schema.Types.ObjectId, ref: "Part", required: true }], cost: { type: Number, required: false }, createdAt: { type: Date }, updatedAt: { type: Date }, }); gcodeFileSchema.index({ name: "text", brand: "text" }); gcodeFileSchema.virtual("id").get(function () { return this._id.toHexString(); }); gcodeFileSchema.set("toJSON", { virtuals: true }); export const gcodeFileModel = mongoose.model("GCodeFile", gcodeFileSchema);