-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Description
Issue type:
[X] question
[ ] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[X] postgres
[ ] sqlite
[ ] sqljs
[ ] websql
TypeORM version:
[X] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Steps to reproduce or a small repository showing the problem:
I have a Source model which can have many Job models
I want to fetch a given source, and together with the most recently created job.
I use this query:
this
.createQueryBuilder('source')
.leftJoinAndMapOne('lastJob', subQuery => {
return subQuery
.select()
.from(Job, 'job')
.orderBy('"createdAt"', 'DESC')
}, 'job', 'job."sourceId" = source.id')
.where('source.id = :id', { id })
.getOne()The above will return the Source, but without the lastJob property
If I you getRawOne
It returns the source properties together with the job properties, but they're not scoped under lastJob
Any ideas?
LucHariman, simonechau, david-minaya and prateekkathal
Metadata
Metadata
Assignees
Labels
No labels