从应用程序引擎NDBdocumentation:
The NDB API provides persistent storage in a schemaless object datastore. It supports automatic caching, sophisticated queries, and atomic transactions. NDB is well-suited to storing structured data records.
我想使用NDB创建如下结构,其中每个实例都是这样的:
{
city: 'SFO'
date: '2013-01-27'
data: {
'keyword1': count1,
'keyword2': count2,
'keyword3': count3,
'keyword4': count4,
'keyword5': count5,
....
}
}
如何使用NDB在Google App Engine(GAE)中设计这样一个无模式的实体?
我是新来的,不知道怎么做到这一点
谢谢你
如果不需要查询数据中的属性,可以使用@voscausa所提到的属性之一:
JsonProperty公司
结构属性:
这里的问题是过滤结构化属性。关键字的属性被视为并行数组。执行查询,例如:
将不正确地包含
my_model
。https://developers.google.com/appengine/docs/python/ndb/queries#filtering_structured_properties
使用expando模型可以工作并允许您查询关键字:
https://developers.google.com/appengine/docs/python/ndb/entities#expando
可以使用
ndb.JsonProperty
来表示模型中的列表、字典或字符串。您可以在documentation中查看更多信息。相关问题 更多 >
编程相关推荐