i have collection page and page has many widgets:
page collection :
_id
name
slug,
widget_codes
widget collection :
_id
name
code
type
product_ids
category_ids
product collection:
_id
name
type
category collection:
_id
name
type
for retrieve data i use like this:
public function getData($page) {
return $page->raw(function ($collection) use ($page) {
return $collection->aggregate([
[
'$lookup' => [
'from' => 'widgets',
'localField' => 'widget_codes',
'foreignField' => 'code',
'as' => 'widgets',
]
],
[
'$match' => ['slug' => $page->slug]
]
]);
});
}
it works perfect and get widget data now i want to get product and category data with widget using that widget has product_ids and category_ids what query can i use.