Custom query: buildSearchQuery not exported

System Information
  • Strapi Version: 3.6.2
  • Operating System: macOS
  • Database: PostgreSQL
  • Node Version: 14.17.0
  • NPM Version: 7.15.0
  • Yarn Version: NA

Hello, I built a custom query, and used the search function in node_modules/strapi-connector-bookshelf/lib/queries.js as an example. Here is that source code:

function search(params, populate) {
  const filters = convertRestQueryParams(_.omit(params, '_q'));

  return model
    .query(qb => qb.where(buildSearchQuery({ model, params })))
    .query(buildQuery({ model, filters }))
    .fetchAll({ withRelated: populate })
    .then(results => results.toJSON());
}

Based on that as an example, I wrote the following to perform my query:

// ...
const rawQueryString = "...";
const rawQueryVariables = [...];
const filters = convertRestQueryParams(...);
const model = strapi.query("recipe").model;
// ...
return model
  .query((qb) => {
    qb.where(buildSearchQuery({ model, params }))
      .whereNot("recipes.published_at", null)
      .whereRaw(rawQueryString, rawQueryVariables);
  })
  .query(buildQuery({ model, filters }))
  .fetchAll()
  .then((results) => results.toJSON());

I require the convertRestQueryParams and buildQuery functions from strapi-utils; however, I am surprised to see that buildSearchQuery is not exported from node_modules/strapi-connector-bookshelf/lib/queries.js.

My custom query operates as expected because I copied and pasted the buildSearchQuery function into my services directory where I wrote my query. But I’m curious if there is a better way to do this that doesn’t necessitate copying and pasting code from node_modules.

Thanks in advance!