ManyToMany Controller
See original GitHub issueHi, first of all thank you for the amazing library.
My situation is the following:
- User entity
export class User {
// ...
@ManyToMany(type => Document, document => document.users)
@JoinTable()
documents: Document[];
}
- Document entity
export class Document {
// ...
@ManyToMany(type => User, user => user.documents)
users: User[];
}
The code above generates a third table (obviously) with userId and documentId. Is there a way to create a controller that exposes “nested endpoints” and that automatically handles this type of relationship (with filters, etc.)?
For example:
- GET /users/:id/documents - retrieves specific user documents
- POST /users/:id/documents - creates the new document and also populates the intermediate table
Issue Analytics
- State:
- Created 4 years ago
- Reactions:19
- Comments:7
Top Results From Across the Web
Many to many relationships in the controller - Stack Overflow
Product and WishList make a Many to Many relationship (at least to me). In a m---m relationship, the belongsToMany() method needs to be ......
Read more >JPA Many to Many example with Hibernate in Spring Boot
Finally, we create controller that provides APIs for CRUD operations: creating, retrieving, updating, deleting and finding Tutorials and Tags.
Read more >Resource Controller for many to many pivot table to enter data ...
I want to do data entry CRUD in joined many to many table via a separate forms from a resource controller actions and...
Read more >Eloquent ORM Many-to-Many Relationships-Laravel | Medium
I have two articles that explain the one-to-one and one-to-many relationships in Laravel, so in this article I'll explain about many-to-many relationships.
Read more >Making Many-to-Many Associations in Controllers
Ruby and Rails · Rails with Active Record; Making Many-to-Many Associations in Controllers. Text. In the last lesson, we covered setting up ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Partially related to https://github.com/nestjsx/crud/issues/239 …which could be taken into account. Features to handle ManyToMany relations and their “middleman” table (ordering, custom fields) would be a powerful addition.
@acepace do you have an example somewhere on how you have it working with the “owning” side?