Under the hood – how it works
You might be wondering how we can perform all of these operations just using API parameters. Does Strapi fetch all the data for a certain model from the database and then filter it according to the API parameters?
Under the hood, Strapi uses Knex.js, a popular multi-dialect SQL builder for Node.js. The API parameters are parsed using a query builder utility; the parsed result can then be used in Knex.js to run the database queries.
Important Note
If you are interested in checking out the filter query builder, you can find the source code in the node_modules/@strapi/database/lib/query/query-builder.js
file.
In the previous chapter, we briefly mentioned the Query Engine API. The Query Engine API allows unrestricted access to the database layer at a lower level. It makes use of the query builder previously mentioned together with Knex.js to run and execute database queries. The Query Engine API is available through strapi.db.query
.