I have a user schema with the sub-schema called project and inside the project I have another schema called boq. How can I populate boqs and projects all in one page without using findById. I can populate projects by User.findById(req.user.id...etc but for projects, I cant use findById. anyway to populate boqs inside projects?
User schema:
var UserSchema = new Schema({ company: String, projects: [ { type: mongoose.Schema.Types.ObjectId, ref: "Project", } ], }); Below is the project schema:
var projectSchema = new Schema({ pname: String, boqs: [ { type: mongoose.Schema.Types.ObjectId, ref: "Boq", } ], }); And boq schema:
var boqSchema = new Schema({ boqHeadIn: String, boqHead: String, boqIn: String, boqDesc: String, boqUnit: String, boqQty: Number, boqRate: Number, boqPrice: Number, });