知识卡片
关系字段表达角色
可独立引用的对象可以通过 ID 相连。若源对象和目标对象之间可能有多个关系,给字段命名时写出职责,例如 creator_user_id。字段的含义可以从业务关系理解,无需猜一个 user_id 代表谁。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Creating an API design using OpenAPI 10.2 Creating the schemas · 查看原书依据
To reference the user who created the job, we can add a field that includes the ID of the user. A common naming approach for these fields is to use the (lowercase) name of the target schema, followed by an underscore, and
参考来源
- 位置:《Designing APIs with Swagger and OpenAPI》第10章《Creating an API design using OpenAPI》(来源项目 book-source:extracted/Designing APIs with Swagger and OpenAPI/_epub-src/OEBPS/Text/ch10.htm,阅读块 93)
- 结论依据:原文用 creator_user_id 区分用户参与同一资源的不同关系。
- 原始内容:To reference the user who created the job, we can add a field that includes the ID of the user. A common naming approach for these fields is to use the (lowercase) name of the target schema, followed by an underscore, and