【发布时间】:2015-04-07 16:31:48
【问题描述】:
我正在使用 Loopback.io 构建一个 API,我一直在思考应该如何设计一些端点。 了解上下文:
a Person hasMany Groups,
a Group hasMany People (and one of them is the admin),
a Member is the "Through" model for Person and Group,
a Group hasMany Sessions.
现在我有 (A):
- /人
- /People/{id}/Groups
- /组
- /Groups/{id}/Sessions
这是 Loopback 生成的 API。 2 和 3 是“重复”端点,但是 2 创建了一个成员实例,而 3 没有。
选项 B:
- /人
- /People/{id}/Groups
- /People/{id}/Groups/{groupId}/Sessions
选项 C:
- /人
- /群组
- /Groups/{id}/Sessions
我想知道哪种方法最好,以及 A 解决方案是否足够好。 非常感谢。
【问题讨论】:
标签: api rest loopbackjs endpoints