google-app-engine - 使用相同的键覆盖写入 google-app-engine 数据存储相同的实体 - 预期吗?

标签 google-app-engine google-cloud-datastore

我有一个数据存储对象,它使用类中的字段之一来创建 key 。假设我有一个对象“a”,该字段的值为“k”。如果我尝试将对象“b”添加到数据存储区,该数据存储区的字段值也为“k”,则对象“b”将覆盖对象“a”。只是想确认这是否是预期的行为。虽然它看起来很明显,但如果有人能解释基本概念那就太好了..

最佳答案

正如 Adam 所解释的,简短的答案是两个实体不能共享相同的 key (想象一个字典)。不过,长答案有点复杂。请参阅docs :

Paths and Key Uniqueness

The complete key of an entity, including the path, the kind and the name or numeric ID, is unique and specific to that entity. The complete key is assigned when the entity is created in the datastore, and none of its parts can change.

The keys of two different entities can have similar parts as long as at least one part is different. For instance, two entities can have the same kind and name if they have different parents. Similarly, two entities can have the same parent (or no parent) and name if they are of different kinds.

An application should not rely on numeric IDs being assigned in increasing order with the order of entity creation. This is generally the case, but not guaranteed.

关于google-app-engine - 使用相同的键覆盖写入 google-app-engine 数据存储相同的实体 - 预期吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2049817/

相关文章:

javascript - 尝试使用 Nodejs 8 加载 GoogleCloud 数据存储模块时出现 "Provided module can' t 加载错误

java - Google App Engine Java 应用程序 : DB Migration

java - Google App Engine 沙箱如何工作?

java - 事务和 ConcurrentModificationException 文档歧义

google-app-engine - 为整个应用程序设置 Python27 Google AppEngine 默认编码

google-app-engine - 使用 Google Cloud Platform 运行 Websockets

entity-framework - 如何让 Appstats 同时显示小操作和读取操作?

google-app-engine - 为什么 Google Appengine 中没有唯一约束?

ruby-on-rails - 如何为查询定义命名空间

google-app-engine - 如何通过ndb数据库(python)中的查询删除记录?