0

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);
2
  • Check this Commented Jun 12, 2020 at 8:25
  • Can you add the error that you are getting? Commented Jun 12, 2020 at 9:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.