in my API that handle all the routes as:
import {Customer} from '../models/customer';
import {DatabaseProvider} from '../database';
export class CustomerService {
public async list(): Promise<Customer[]> {
const connection = await DatabaseProvider.getConnection();
return await connection.getRepository(Customer).find();
}
public async delete(id: number): Promise<void> {
const connection = await DatabaseProvider.getConnection();
return await connection.getRepository(Customer).removeById(id)
}
}
export const customerService = new CustomerService();
this works well but is there any way to call getConnection() automatically without rewrite it in any method?
^
Обсуждают сегодня