Open qstyler opened 1 year ago
…param
Allows @Crud decorator accept loadRelationIds query param that is later accepted by TypeORM.
@Crud
loadRelationIds
Please check if your PR fulfills the following requirements:
yarn commit
What kind of change does this PR introduce?
[ ] Bugfix [x] Feature [ ] Code style update (formatting, local variables) [ ] Refactoring (no functional changes, no api changes) [ ] Build related changes [ ] Tests [ ] Release [ ] CI related changes [ ] Other... Please describe:
Issue Number: N/A
Introduces loadRelationIds, a new field in QueryOptions. That is passed to TypeORM.
QueryOptions
This allows the loading of relations ids in objects without joining the whole table.
For example this controller:
@Crud({ model: { type: UserLicense }, query: { loadRelationIds: { relations: ['license'], disableMixedMap: true, }, }, }) @Controller('user.licenses') class UserLicenseController { constructor(public service: UserLicenseService) {} }
getting all records will return this:
[ { "userId": 1, "licenseId": 1, "yearsActive": 3, "license": { "id": 1 } }, { "userId": 1, "licenseId": 2, "yearsActive": 5, "license": { "id": 2 } }, { "userId": 1, "licenseId": 4, "yearsActive": 7, "license": { "id": 4 } }, { "userId": 2, "licenseId": 5, "yearsActive": 1, "license": { "id": 5 } } ]
This is very useful for building rest APIs without @RelationId() and @Column() hacks.
@RelationId()
@Column()
[ ] Yes [x] No
@qstyler This repo seems to not be supported anymore, would you like to submit your PR to this forked repo, which is more up-to-date? Thanks!
https://github.com/gid-oss/dataui-nestjs-crud
…param
Allows
@Crud
decorator acceptloadRelationIds
query param that is later accepted by TypeORM.PR Checklist
Please check if your PR fulfills the following requirements:
yarn commit
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behaviour?
Introduces
loadRelationIds
, a new field inQueryOptions
. That is passed to TypeORM.This allows the loading of relations ids in objects without joining the whole table.
For example this controller:
getting all records will return this:
This is very useful for building rest APIs without
@RelationId()
and@Column()
hacks.Does this PR introduce a breaking change?