How can I implement a "starts_with" filter?

System Information
  • Strapi Version: 3.4.0
  • Database: PostgresDB

Hi,

I need to implement a “starts_with” filter so that I can query every entry with a name that starts with an “A” or a “B” etc.

Is there a way I can create my own filter? https://strapi.io/documentation/developer-docs/latest/plugins/graphql.html#filters

I’m sorry to “up” this post. But I’m still blocked.

So I’m trying to implement a custom query.

In my service file:

 module.exports = {
  find(params, populate) {
    return strapi.query("restaurant").find(params, populate);
  },
}

Concretely, how can I extend this find function (or find its source code) to add my starts_with filter? I know that with Bookshelf I can do something like:

  await strapi
    .query('restaurant')
    .model.query(qb => {
      qb.where('id', "like", `${params.name_starts_with}%`);
    })
    .fetch();

But I’m missing a brick. I need the source code of strapi.query("restaurant").find(params, populate);