【问题标题】:What is the best practice to store multi valued/repeated data in google datastore?在谷歌数据存储中存储多值/重复数据的最佳做法是什么?
【发布时间】:2012-08-22 14:21:57
【问题描述】:
我有一个简单的场景,我有 4 个实体。
目的地:名称、位置、标签(多值)、创建、上次修改、创建者、上次修改者
Trip:包含多个目的地、名称、标签(多值)、创建、最后修改、创建者、最后修改者
-
问题:问题,多个答案,创建者,最后修改者,创建者,最后修改者
答案:目的地(多个),旅行(多个), 创建者, 最后修改者, 创建者, 最后修改者
我正在使用 Google 数据存储。存储此类数据的最佳方法应该是什么?
【问题讨论】:
标签:
google-app-engine
nosql
google-cloud-datastore
【解决方案1】:
我想我找到了问题的答案。现在我在Google Datastore 中使用ndb.KeyProperty 来解决我的问题。
class Trip(ndb.Model):
name = ndb.StringProperty()
details = ndb.TextProperty()
turl = ndb.StringProperty()
links = ndb.StringProperty(repeated = True)
tags = ndb.StringProperty(repeated = True)
destinations = ndb.KeyProperty(Destination1, repeated = True)
class Destination1(ndb.Model):
name = ndb.StringProperty()
location = ndb.StringProperty()
durl = ndb.StringProperty()
description = ndb.StringProperty()
deatils = ndb.StringProperty()
tags = ndb.StringProperty(repeated = True)
links = ndb.StringProperty(repeated = True)
我之前使用的StructredProperty 不支持嵌套repeated=True 的概念。