I’m having trouble returning a correct filter, but I believe I’m not doing it correctly.
I’m making a query for the COMPONENT table, this table has correlation with the SUPPORT table.
Need: I need to return the last 2 records where the STATUS of the SUPPORT table is equal to DONE but with the code below it is returning the last 2 records, regardless of whether the status is DONE or another.
Note: both tables have the STATUS column, I need the status DONE in both.
I believe it is something simple for an experienced professional to solve, but I am not able to do so…
const statusQuery = await strapi.db.query('api::component.component').findMany({
where: {
$and: [
{
status: "Done",
support: { status: 'Done' },
},
],
},
select: ['name', 'status'],
limit: [2],
populate: { support: { select: ['name', 'status'], }, },
orderBy: [ { updatedAt: 'desc', }, ],
});