Closed OliveiraCleidson closed 1 year ago
Hello @OliveiraCleidson ,
So step by step :)
filters[threadOf][$null]=true
It causes 500 because of following error and that's purely Strapi error. I assume the case here is with relation property.
{
threadOf: { '$null': 'true' },
'$or': [ { removed: [Object] }, { removed: false } ],
related: 'api::page.page:1'
}
[2023-04-07 15:47:25.215] error: Only $and, $or and $not can only be used as root level operators. Found $null.
Error: Only $and, $or and $not can only be used as root level operators. Found $null.
at processWhere (/Users/mziarko/Projects/open-source/strapi-v4/node_modules/@strapi/database/lib/query/helpers/where.js:140:13)
at processNested (/Users/mziarko/Projects/open-source/strapi-v4/node_modules/@strapi/database/lib/query/helpers/where.js:116:12)
at processWhere (/Users/mziarko/Projects/open-source/strapi-v4/node_modules/@strapi/database/lib/query/helpers/where.js:161:25)
filters[threadOf][id][$null]=true
This returned value is our error in reality as we're getting 1:1 from query. I will fix that in next release, but such query is correct.
threadFirstItemId
is not DB field but calculated property. You can't query by it.Exists a method that gets only root comments in a request?
I can work on this fix.
Nope, there is no such dedicated method - ideally it should be done by the way you described.
If you can fix point 2. we would be grateful :) Should be fairly quick one liner at the end of service method.
Released as part of v2.2.10
How to filter only comments that are not in a thread
I'm working on one feature that gets comments with pagination. I won't get comments sorted by created date and only comments that are root comments, then I'm using the REST API in flat mode.
Bugs (?)
But when I try to filter using
threadOf
the server returns 5xx.When I use
threadOf
with id, thethreadOf
field does not return the correct content innerthreadOf
, but the filter works.When I try to use
threadFirstItemId
My dependencies:
My
plugin.ts
My node version Is 16.17.0