Hey guys, I'm trying to run a MongoDB aggregation operation. While the overall process works fine, I'm having trouble passing a where filter dynamically. Is there a function in db-mongodb or any other way to convert a where filter?
A little context: I want to get items that are available for filters in the frontend. And I need to pass the where query, so that I only get the avaliable options…
For example, if I want to filter by a relationship, I currently have to do something like this:
const aggregatedItems = await payload.db.collections['products']?.aggregate(
[
{
$match: {
'technicalData.type': new ObjectId('68347c88395adc242ad720f3'),
},
},
// ...
],
);
In reality, the filters are more complex than just a simple relation. Any Ideas?