Seeking advice on creating a versatile function in TypeScript and TypeORM
I currently have numerous functions structured like this:
async getOrderName(id: number): Promise<string> {
const order = await this.conn.getRepository(Order).findOne(id);
return `${order.name}`;
}
async getServiceName(id: number): Promise<string> {
const service = await this.conn.getRepository(Service).findOne(id);
return `${service.name}`;
}
and the list goes on... I am looking to develop a single generic function that can be utilized across multiple entities
If anyone has insight on how to go about creating such a function, please share!