correct-apricot
correct-apricot6mo ago

How to filter null dates

The following code tries to filter the field "endDate" by only null/undefined values but it is not working const lastWorkingHourList = useSimpleList({ resource: 'employee-working-hours', filters: { permanent: [ { field: 'endDate', value: null, operator: 'eq' } ] } });
2 Replies
kapa.ai
kapa.ai6mo ago
Hi @Facu. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the extracts, it seems like there might be an issue with the way you're trying to filter for null values. In some cases, using the 'eq' operator with a null value might not work as expected. In one of the GitHub issues related to the Strapi provider, it was mentioned that using 'eq' with null can cause a 500 error. Instead, they suggested using a different format for querying null values, like <http://localhost:1337/api/posts?filters**content][$null]=true> ([source (https://github.com/refinedev/refine/issues/3417)). However, it's important to note that the behavior might vary depending on the data provider you're using. If you're using the Hasura provider, for example, you might need to use the 'null' operator instead of 'eq' when you want to filter by null values. This was suggested in a different GitHub issue, where it was mentioned that using 'null' and 'nnull' filters should be converted to '_isNull' when using the 'graphql-default' naming convention (source** (https://github.com/refinedev/refine/issues/4972)). Here's how you might adjust your code:
const lastWorkingHourList = useSimpleList({
resource: 'employee-working-hours',
filters: {
permanent: [
{
field: 'endDate',
value: true,
operator: 'null'
}
]
}
});
const lastWorkingHourList = useSimpleList({
resource: 'employee-working-hours',
filters: {
permanent: [
{
field: 'endDate',
value: true,
operator: 'null'
}
]
}
});
Please note that this is just a suggestion based on the information available in the extracts. You might need to adjust this based on the specific requirements of your data provider. If you continue to experience issues, I would recommend checking the documentation or reaching out to the community for further assistance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai6mo ago
<@411223164698492929> kapa.ai is still learning and improving, please let us know how it did by reacting below