什么是好的数据库属性,一个键的数组python与App Engine? [英] What is the good db property, for an keys's array for python with App Engine?

查看:121
本文介绍了什么是好的数据库属性,一个键的数组python与App Engine?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于时刻,条表示一个带有所有条形码的字符串,带有';'分隔符

For the moments bars represents a String with all the Bar ids with ';' separator

6; 5; 9; 15

class Foo(db.Model):
    id = db.StringProperty(multiline=True)
    name = db.StringProperty(multiline=True)   
    bars = db.TextProperty()

class Bar(db.Model):
    id = db.StringProperty(multiline=True)
    name = db.StringProperty(multiline=True)

我应该怎么做显式的Foo包含db中的一些吧?
还有怎么看我的:

What must I do to explicit Foo contains some bars in db? And also how is going to look my :

f = Foo()
f.name= 'aName'
f.id = '3615'
f.bars = '6;5;9;15'
f.put()


推荐答案

为了开始,您不希望在单个文本框中存储多个值。 AppEngine的数据存储支持多值属性(例如 ListProperty ):您应该使用这些。

For a start, you never want to store multiple values inside a single textfield. AppEngine's datastore supports multi-valued properties (such as ListProperty): you should use those.

没有多值等价物 ReferenceProperty 内置。 AppEngine文档网站上的这篇文章给出了如何建模一个键列表的一个很好的例子。

That said, there's no multi-valued equivalent of ReferenceProperty built in. This article on the AppEngine documentation site gives a good example of how to model a list of keys.

这篇关于什么是好的数据库属性,一个键的数组python与App Engine?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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