Hey all,
I'm currently facing difficulties with implementing a filter in Directus and I'm unable to achieve the desired result.
Here's the code I'm using:
const { data: investments } = await useAsyncData('investments', () => { return $directus .items('investments') .readOne(1, { fields: [ 'title', 'subtitle', 'investments.sort', 'investments.item.header_img', 'investments.item.title', 'investments.item.subtitle', 'investments.item.type', 'investments.item.square_footage_max', 'investments.item.square_footage_min', ], }); });
The code returns:
{ "title": "Wynajem", "subtitle": "Otwórz swój lokal w najbardziej prestiżowych lokalizacjach Gdyni.", "investments": [ { "sort": 1, "item": { "header_img": "68b4de94-0219-4425-9fd9-96e63334f385", "title": "Plac Kaszubski", "subtitle": "W samym sercu miasta", "type": [ "usługowy", "gastronomiczny" ], "square_footage_max": "250", "square_footage_min": "250" } }, // ... } ] }
The investment field is M2A. I'm specifically trying to filter by the square_footage_min and square_footage_max variables, but I'm encountering issues accessing these values. I've attempted to use filter and deep methods. While I managed to apply filtering successfully using deep for testing purposes with the sort option, I'm struggling to achieve the desired effect when applying the filter to the fields in item. In some cases, I get a null response, while in others, all items are returned.
deep: { investments: { _filter: { sort: { _eq: 1 } } }, }
How to get to for example square_footage_max from deep or any other value under item?