import { EntityRepository , Repository } from 'typeorm' ; import { OrderProduct } from '../models/OrderProduct' ; @ EntityRepository ( OrderProduct ) export class OrderProductRepository extends Repository < OrderProduct > { public async List ( limit ) { const query = await this . manager . createQueryBuilder ( OrderProduct , 'orderProduct' ) ; query . select ( [ 'DISTINCT product_id as productId' , 'order_id as orderId' , 'name as ProductName' , 'quantity as Quantity' , 'total as Total' , ' created_date as CreatedDate' ] ) ; query . orderBy ( 'created_date' , 'DESC' ) ; query . limit ( limit ) ; return query . getRawMany ( ) ; } }