Search code examples
strapi

What is "_q" in the "ctx.query._q" for?


til today, I have never had the situation when ctx.query._q === true (in find: async (ctx) => {...}). Instead, I've always defined ctx.query, like:

I can already find almost everything I need. My question: what is _q for?

query = {
   col0: ctx.request.body.col0,
   col1: ctx.request.body.col1,
   col2: ctx.request.body.col2
   …
};

Can someone explain that to me? Maybe with an example?

Thanks a lot!


Solution

  • In the find controller function, the ctx.query represent the query params of your request.

    For example https://localhost:1337/restaurants?_q=french

    In your case ctx.request.body come from the data you send in a POST request.