如何为同一实体之间的多个关系选择API端点?

发布于 2025-02-07 04:46:18 字数 260 浏览 1 评论 0原文

我很难为两个类似的查询选择终点。因此,我的数据库实体是用户和当然,他们之间有2个关系。第一个关系是与M:用户正在学习许多课程,并且许多用户可以学习课程。第二个关系是1到M:可以由一个用户编辑课程,并且用户可以编辑许多课程。现在,对于API端点,我需要获取:

  1. 用户正在学习
  2. 用户可以编辑的所有课程,

我只能看到/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:

  1. all the courses a user is learning
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟雨扶苏 2025-02-14 04:46:18

该怎么办:

/users/me/editable-courses
/users/me/joined-courses

What about:

/users/me/editable-courses
/users/me/joined-courses
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文