Hi I have this kind of data :
{
id: 2,
name: ‘adidas2’,
model: ‘vdpozozdvz’,
complete_info: [
[{
hour: null,
price: ‘90’,
isnew: true,
}],
[{
hour: null,
price: ‘90’,
isnew: true,
}],
[{
hour: null,
price: ‘90’,
isnew: true,
}],
…
}
I’m doing a cron job that every day at midnight the “isnew” field in “complete_info” turn to false
so I find with strapi method all the response :
const res = await strapi.services.restaurant.find()
but what I want is to fond only the res with a “isnew” field at true
something like this :
const res = await strapi.services.restaurant.find({complete_info.isnew : true})
but I don’t understand the syntaxe to filter on the component
thank you
Hello, currently it’s not possible to filter reapetable components.
Take a look at this issue:
opened 12:15PM - 29 Jan 20 UTC
type: feature request
severity: medium
- [ ] **I have created my request on the Product Board before I submitted this i… ssue**
- [x] **I have looked at all the other requests on the Product Board before I submitted this issue**
Hi!
Recently I tried to limit the amount of items that are in the object of a repeatable component. I'm not 100% sure this should be done with a custom query, but it would be nice to have the ability to limit/start or use a where query on repeatable component objects in GraphQL. One-to-many relations have the ability to set a query for a nested field. Components however, do not.
If I've missed any possible solution digging through the existing issues, please let know.
**Edit by** @derrickmehaffy
Filtering with GraphQL and REST on the polymorphic components
hi @sunnyson , and thank you for your awnser
my question echoed to this New Feature with cron and job - #8 by Gabriel_Eliade
where you tell me to get only elements wich have isnew equal to true
that’s why I was asking
Might have missed that it was a component, but Sunny is correct you can’t filter on components via Strapi methods, you will need to use the ORM directly or create a custom query
https://strapi.io/documentation/developer-docs/latest/concepts/queries.html#custom-queries
1 Like
Pong420
October 27, 2021, 10:01am
7
How to use mongoose to create a custom query to filter component value ?
Anyone have any idea how to filer components? @ sunnyson I’m new and I’m struggling with this one.
You can’t filter on components in the v3, this is a feature we are adding in our coming v4
I’m running v4 and still unable to find how to filter on components, neither with REST or GraphQL. Any idea?
3 Likes
galago
June 6, 2022, 9:17am
11
any update on this in v4?
Thanks
I’m using replit here just to show how you would construct the filters and population in the qs package but you could also write the LHS bracket syntax manually. All of this is in our documentation.
Example QS structure:
Actual request:
Docs for REST: REST API - Strapi Developer Docs
Docs for GraphQL: GraphQL API - Strapi Developer Docs