如何为同一实体之间的多个关系选择API端点?
我很难为两个类似的查询选择终点。因此,我的数据库实体是用户和当然,他们之间有2个关系。第一个关系是与M:用户正在学习许多课程,并且许多用户可以学习课程。第二个关系是1到M:可以由一个用户编辑课程,并且用户可以编辑许多课程。现在,对于API端点,我需要获取:
- 用户正在学习
- 用户可以编辑的所有课程,
我只能看到/users/Me/Courses
作为潜在的端点,但是如何如何我区分我想要基于末端的查询的关系吗?
I'm having trouble picking end points for two similar queries. So my db entities are User and Course, they have 2 relationships between them. The first relationship is M to M: A user is learning many courses and a course can be learned by many users. The second relationship is 1 to M: a course can be edited by one user and a user can edit many courses. Now for the API endpoints, I need to get:
- all the courses a user is learning
- all the courses a user can edit
I can only see /users/me/courses
as a potential endpoint, but how do I distinguish between the relationships that I want the query based on in the end-point?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该怎么办:
What about: