I am trying to get many rows and the count at the same time, so i am using getManyAndCount() this returns the data, but there is a relationship with another entity which I want to get, but this returns null
I tryied with getRawMany() which returns all the data that I need, but I don't get the count. So I am trying the next code
cobranza = await cobranzaRepository
.createQueryBuilder('cobranzas')
.leftJoinAndSelect('cobranzas.alumno', 'alumno', 'alumno.nombre like :name', {
name: '%' + req.query.alumno.toUpperCase() + '%',
})
.select([
'cobranzas.id',
'cobranzas.tipopago',
'cobranzas.importepagado',
'cobranzas.periodo',
'cobranzas.createdAt',
'cobranzas.recibo',
])
.addSelect(['alumno.nombre', 'alumno.apellidopaterno', 'alumno.apellidomaterno'])
.skip(req.query.skip)
.take(req.query.per_page)
.getManyAndCount();
I expect
{
"id": 22,
"tipopago": 1,
"importepagado": "500",
"periodo": "SEM-11-2019",
"createdAt": "2018-12-13T00:52:36.338Z",
"alumno": {
"id": 6,
"nombre": "MARTIN",
"apellidopaterno": "LOPEZ",
}
}
But the actual output is
{
"id": 22,
"tipopago": 1,
"importepagado": "500",
"periodo": "SEM-11-2019",
"createdAt": "2018-12-13T00:52:36.338Z",
"alumno": null
}