使用 Google App Engine 和 ndb 时是否曾看到重复的 ID? [英] Ever see duplicate IDs when using Google App Engine and ndb?

查看:26
本文介绍了使用 Google App Engine 和 ndb 时是否曾看到重复的 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

class Entries(ndb.Model):
  description = ndb.StringProperty()
  seqid = ndb.IntegerProperty()
  link = ndb.StringProperty()
  group = ndb.StringProperty()
  timestamp = ndb.StringProperty()
  referrals = ndb.StringProperty(repeated=True)

图片中的两个条目是由两个不同的用户创建的.用户是条目的父级.

The two entries in the picture are created by two different users. The user is the parent of the Entry.

我在生产中获得了重复的 ID,但在本地却没有.此外,它始终是相同的 ID 号(但肯定不会在任何地方进行硬编码)

I get a duplicate ID on production but not on local. Also, it's always this same id number (but it is certainly not hard coded anywhere)

由于父级是用户,我仍然可以将其作为唯一条目拉取,但这意味着如果我有两个条目属于同一个父级用户,就会出现问题.

As the parent is the user, i can still pull it as a unique entry but it will mean there will be problems if I have two entries with the same parent user.

推荐答案

数据存储区的唯一键是完全限定键,包括所有父实体键,而不仅仅是 ID.具有相同 ID 和不同父级的多个实体是完全有效的,您不应仅依赖 id 的唯一性.

A datastore's unique key is the fully qualified key, including all parent entity keys, not just the ID. Multiple entities with the same ID and different parents are completely valid, and you shouldn't rely on the id alone being unique.

这篇关于使用 Google App Engine 和 ndb 时是否曾看到重复的 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆