正确使用重复属性?
我需要允许许多商品的订单/购买,例如
class Purchase(db.Model):
'''a completed transaction'''
item = db.ReferenceProperty(Item, repeated=True))
重复的关键字是否合法并以正确的方式使用?我还有哪些其他选择?我应该用重复的字符串属性来代替吗?
item_ids = model.StringProperty(repeated=True)
或重复的 KeyProperties? 谢谢
I need orders / purchases that allow many items for instance something like
class Purchase(db.Model):
'''a completed transaction'''
item = db.ReferenceProperty(Item, repeated=True))
Is the repeated keyword legal and used in the correct manner here? What are my other options? Should I do it with a repeated stringproperty instead?
item_ids = model.StringProperty(repeated=True)
or with repeated KeyProperties?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个 ListProperty:
它的使用方式与 python 类似列表:
但在查询中它看起来像一个单值字段。 ListProperty 的每个值都单独索引。
下面的查询将返回包含
item1
的所有购买:下面的查询将返回包含
item1
或item2
的所有购买:如果您需要要对多个 ListProperty 建立索引,请不要忘记熟悉 爆炸索引。
There is a ListProperty:
It is used like a python list:
In queries however it looks like a single-valued field. Every value of ListProperty is indexed separately.
Query below will return all purchases which contain the
item1
:Query below will return all purchases which contain either
item1
oritem2
:If you will ever need to index more than one ListProperty don't forget to familiarize your self with exploding-indexes.