我在appengine上有一个python模块和一个go模块。go模块相当简单,只提供了一个只读的搜索接口到python模块填充的数据存储。在
如何将以下ndb模型转换为go结构:
class Course(ndb.Model):
name = ndb.StringProperty()
neat_name = ndb.StringProperty(required=True)
country = ndb.KeyProperty(kind=Country, required=True)
university = ndb.KeyProperty(kind=University, required=True)
faculty = ndb.KeyProperty(kind=Faculty, required=True)
department = ndb.KeyProperty(kind=Department, required=True)
stage = ndb.KeyProperty(kind=Stage, required=True)
legacy_id = ndb.StringProperty()
course_title = ndb.StringProperty(required=True, indexed=False)
course_description = ndb.TextProperty(required=True)
course_link = ndb.StringProperty(required=True, indexed=False)
#0-5 or None or not has attribute.
course_rating_ = ndb.FloatProperty()
course_review_count_ = ndb.IntegerProperty()
首先,我要:
^{pr2}$对于ndb.KeyProperty
属性,我是否只在struct
中使用string
?&我要解析这个字符串-这是直接的吗?在
我也可以忽略required=True
&;indexed=False
选项吗?显然因为我不写任何东西?在
每^{{{a1},};^{{}(一个长字符串达1MB,不索引)也去{{}},但始终与{{};对于数据存储{{}}有{{{}},见{{a2};对于{{a2};对于{{a2};对于{{a2};对于^{{cd8>}{{{}},};对于}{{{{{{},
String
(一个短串最多500个字符,默认索引索引索引)地图去去^{{int64
};对于{float64
(您可以使用较短的int和float,但是数据存储对每个都使用64位,所以您可以好吧:-). 在对
required
是的,但我相信,使用https://cloud.google.com/appengine/docs/go/datastore/reference,您确实必须对Text
使用选项noindex
,因为必须指示长度超过512(unicode)字符的字符串。在不确定是哪个版本的
go
及其datastore
包强制执行此约束,但即使当前的版本没有这样做,还是更安全地遵守它,否则你的应用程序可能会因为一个简单的Go版本升级而崩溃!-)在以下是代码-它也在生产和本地工作:
以及
^{pr2}$相关问题 更多 >
编程相关推荐