Wednesday 24 May 2017

Type-orm: orderby in joined select

I have this query. 'Contracts' is a list of object. I would like to order the list by a date property. How can I do this?

export function searchServiceContractsFull (searchString: string | number, conn: Connection): Promise<ServiceContract[]> {
  return conn.getRepository(entity.ServiceContract).createQueryBuilder('serviceContract')
    .leftJoinAndSelect('serviceContract.operations', 'operations')
    .leftJoinAndSelect('operations.user', 'op_user')
    .where('serviceContract.service_contract_id = :id', {id: searchString})
    .orWhere('vehicle.registration_number = :str', {str: searchString})
    .orWhere('contactPerson.email = :email', {email: searchString})
    .orderBy('serviceContract.entity_created', 'DESC')
    .getMany()
}



via olefrank

No comments:

Post a Comment