I am creating a global function in my scaffolder so that the template can pass a value to this function and I will search up a related entity from the catalog and return it.
This is how I am creating my global function in scaffolder.ts
const additionalTemplateGlobals: Record<string, TemplateGlobal> = {
getEntityFromRef: ref => getEntityFromRef(ref as string, env.database),
};
Looking at the source, it seems like I can get the client by doing something like const client = await env.database.getClient() and then I can do normal Knex stuff on this client object. Is this correct? Is this the best way or is there a better way to do it? Is there a helper function that I can call instead of needing to create a knex client?