How to bind .query property onto strapi object

You can do this inside the bootstrap function.

An example of how I bind a long query:
/config/bootstrap.js:

module.exports = async () => {

strapi.getConfigs = async function () {
       return strapi.query('my-custom-configs', 'my-custom-plugin-with-configs').findOne();
    }
}

Now in all my project, I can call strapi.getConfigs()

Bootstrap.js documentation: https://strapi.io/documentation/developer-docs/latest/concepts/configurations.html#bootstrap

1 Like