Problems with nested controller routes / nested route params
See original GitHub issueI have used this library in conjunction with nestjs for almost a year now. Nest by istelf for 2, so I am fairly familiar with the API of both. Thank you for this work as it has been very nice to use overall.
https://github.com/nestjsx/crud/wiki/Controllers#get-one-resource
First off I think there may be a bug in the documentation:
It looks like you are missing a forward slash after perks.
Secondly, I have not been able to get nested routes to work at any point. An example of a nested route being something such as this:
/heroes/:heroId/perks/:id
The documentation kind of explains for this case:
If you have a controller path with that looks kinda similar to this /companies/:companyId/users you need to add this param option:
@Crud({ ... params: { ... companyId: { field: 'companyId', type: 'number' }, }, ... })
But it doesn’t show you what the entities look like on the back end to make this happen. I think this is of key importance to get this to work.
- Does one need to name id fields like ‘companyId’ in the entity or can ‘id’ suffice?
- How deeply nested can one go using this pattern?
- What does a complete example of this pattern look like?
This part of the documentation is seriously lacking. If I could get this feature to work I would consider adding a PR, but like I said, I have yet to be able to use this feature.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:11
Hello @Jtosbornex! No, the eager join is not mandatory. Checkout my latest commit because there was an issue in my previous commit :
https://github.com/shinework/nest-crud-nested-controller
And you have to explicitly add a
authorId
field :Calling http://localhost:3000/authors/1/articles/3 results to:
http://localhost:3000/authors/1/articles:
🤘
@avchugaev
I think you need to explicitly add in the following:
@Column() school_id:number;