How to perform JSON type filed nested attribute filter?

System Information
  • Strapi Version: 3.4.4
  • Operating System: Linux
  • Database: Mongo
  • Node Version: v12.20.1
  • NPM Version: 6.14.10
  • Yarn Version: 1.22.5

Hi there dear Strapi comunity, I have latest strapi installed, and I have mongo collection with JSON type field. I need to filter by the range of values within that JSON field but getting the following type error:
“Your filters contain a field ‘course.price’ that doesn’t appear on your model definition nor it’s relations”

Here is the filter in Url:
mycollecion?course.price_gte=100&course.price_lte=500

Here is the field in my model setting file:
/// api/mycollecion/models/MyCollecion.settings.json

“course”: {
“default”: “”,
“type”: “json”
},

as you can see course field is just a json and I have price field within it. As I understood the code tries to find course.price named field in model or it tries to get course relation. My case is just nested field in mongo db.

Let me know if you need additional information,
Thank you

Currently we don’t support json field filtering as not all of our supported databases offer this feature.

If you absolutely need something like this, you will need to build your own/modify the existing controller/service and construct a custom query: https://strapi.io/documentation/developer-docs/latest/concepts/queries.html#custom-queries

1 Like

OK, Thank you!