简体   繁体   English

哪个层/组件应生成UUID?

[英]Which layer/component should generate an UUID?

Considering a 考虑一个

  • distributed, decentralized, REST API for a single page application, 适用于单页应用程序的分布式,分散式REST API,

  • used world-wide, 在世界范围内使用,

  • in which the entity ids are UUIDs, 其中实体ID是UUID,

which application layer should be responsible for the UUID generation for an entity insertion? 哪个应用层应负责为实体插入生成UUID?

A few options: REST client application? 一些选择:REST客户端应用程序? REST implementation? REST实现? Data base? 数据库?

It depends on your code and platform. 这取决于您的代码和平台。 If your database supports generating ID you should prefer that. 如果您的数据库支持生成ID,则应该使用该ID。 In case you have to generate it in your API implementation, prefer generating it in model of your framework. 如果必须在API实现中生成它,则最好在框架模型中生成它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM