Relasi product dengan tag one to many
Closed this issue · 0 comments
AnggaWikaNugraha commented
await Product
.find({_id: 'p123'})
.populate('category')
.populate('tags') // <---
{
_id: ObjectId('p123'),
name: 'Hot Americano',
price: 25000,
description: 'Hot black coffee',
category: {
_id: ObjectId('abc'),
name: 'Minuman'
},
tags: [
{ _id: ObjectId('123'), name: 'Coffee'},
{ _id: ObjectId('345'), name: 'Hot'}
]
}