Below is my orderSchema. So I want this orderSchema to save array of Dishes(Items) which basically is another schema (dishSchema). Currently, I am using the commented syntax which basically throwing an error. Any other way to do that?
Thank's in advance.
const mongoose = require("mongoose");
const orderSchema = mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
cost: { type: String, required: true },
resId: {
type: mongoose.Schema.Types.ObjectId,
required: true,
ref: "Restaraunt",
},
userID: {
type: mongoose.Schema.Types.ObjectId,
required: true,
ref: "User",
},
//Items: [{ type: mongoose.Schema.Types.ObjectId, ref: "Dish" }],
totalItems: {
type: Number,
required: true
}
});
module.exports = mongoose.model("Order", orderSchema);