Reputation: 11
document:
// inside Category Schema
"category": {
"_id": "5f50be253fe4b520fee4114e",
"name": "health Care",
"subCategories": [
{
"_id": "5f50c2a4b90c0724832a1d7e",
"name": "Shop"
},
{
"_id": "5f50c2a4b90c0724832a1d7f",
"name": "health tonic"
},
{
"_id": "5f50c2a4b90c0724832a1d80",
"name": "protin"
},
],
},
Product Schema
const productSchema = new mongoose.Schema({
subCategory : {
type: mongoose.Schema.Types.ObjectId,
}
})
stored in db subCategory: 5f50c2a4b90c0724832a1d7f,
how can populate Subcategory
Upvotes: 1
Views: 35