我是google-app-engine和google datastore(bigtable)的新手,我有些疑惑,这可能是设计所需数据模型的最佳方法.
我需要创建一个层次结构模型,类似于产品目录,每个域都有一些深层子域.目前,产品的结构变化小于读取要求.葡萄酒示例:
所有关系都是不相交和不完整的.此外,按照要求的顺序,我们可能需要存储每种葡萄酒的使用计数器(可能需要交易)
根据文档的顺序,似乎有不同的潜在解决方案:
但是为了获得葡萄酒的预期要求......有时候是按品种,有时是原产地,有时是酒庄...我担心使用这些结构的查询的行为(比如关系模型中的多个连接).如果你要求一个家庭的产品...你需要加入产品树的最后深度限定符,并加入自家庭以来)
也许最好创建一些重复的信息(按照谷歌团队的建议顺序:操作很昂贵,但存储不是,所以不应该看到重复的内容是主要问题)
其他类似问题的一些回答表明:
有什么建议?
嗨,威尔,
我们的情况更像是一种严格的分层方法,如第二个例子所示.并且查询用于检索产品列表,只检索一个不常见的.
我们需要从Origin,Winery或Variety中检索所有葡萄酒(如果我们认为该品种是严格分层树的另一个节点,仅仅是一个例子)
一种方法可能是包含路径属性,如您所述:
允许我从应用如下查询的各种葡萄酒中检索葡萄酒列表:
wines_query = Wine.all()
wines_query.filter('key_name >','/origin/toscana/winery/latoscana/variety/merlot/')
wines_query.filter('key_name <','/origin/toscana/winery/latoscana/variety/merlot/zzzzzzzz')
Run Code Online (Sandbox Code Playgroud)
或者来自Origin:
wines_query = Wine.all()
wines_query.filter('key_name >','/origin/toscana/')
wines_query.filter('key_name <','/origin/toscana/zzzzzz')
Run Code Online (Sandbox Code Playgroud)
谢谢!
我有一个iOs应用程序的sqlite3数据库,以便为系统提供离线支持.
它完美地运作.但有时.db文件已损坏.而且不会返回结果.
如果我通过命令行检查SELECT指令,我会收到下一条错误消息:
sqllite Error: database disk image is malformed
Run Code Online (Sandbox Code Playgroud)
虽然不可取,但它会变得腐败.数据库只是一个辅助系统,足以能够从iOS应用程序检测到文件已损坏并重新启动文件.
但是使用sqlite3语句我没有得到任何异常.代码如下:
sqlRaw = @"SELECT ... ";
const char *sql = [sqlRaw cStringUsingEncoding:NSUTF8StringEncoding];
if (sqlite3_prepare_v2(database, sql, -1, &date_statement, NULL) != SQLITE_OK) {
NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
}
NSMutableArray *entities = [[NSMutableArray alloc] initWithCapacity:0];
while (sqlite3_step(date_statement) == SQLITE_ROW) {
NSData *entityXml = [[NSData alloc] initWithBytes:sqlite3_column_blob(date_statement, 0)
length:sqlite3_column_bytes(date_statement, 0)];
[entities addObject:entityXml];
}
sqlite3_finalize(date_statement);
Run Code Online (Sandbox Code Playgroud)
当应用程序执行前面的代码时,只返回一个空数组,不会抛出任何异常.
有谁知道如何从sqlite3语句检查.db文件状态?
也许用户其他存储系统更好.有什么建议?
当我使用POST使用json参数向GAE发送POST消息时,服务器解析的QueryDict不像json那样被解析...
我在这个问题上发现了一个类似的问题:对Django服务器的iphone Json POST请求在QueryDict中创建了QueryDict
可能是GAE配置存在问题.我使用最新版GAE的Python 2.6.6.首先,如果我使用nc工具获得POST,POST消息是完美的:
POST /url/ HTTP/1.1
Accept: application/jsonrequest
Content-type: application/json
Accept-Encoding: gzip
Content-Length: 458
Host: 192.168.1.1:8080
Connection: Keep-Alive
{"id":"xxx","jsonrpc":"2.0","method":"XXX","params":{...}]}
Run Code Online (Sandbox Code Playgroud)
在服务器控制台中,我收到下一条消息:
DEBUG 2010-09-16 06:47:05,891 dev_appserver.py:1693] Access to module file denied: /usr/lib/pymodules/python2.6/simplejson
DEBUG 2010-09-16 06:47:05,894 dev_appserver.py:1700] Could not import "_json": Disallowed C-extension or built-in module
DEBUG 2010-09-16 06:47:05,897 dev_appserver.py:1700] Could not import "_json": Disallowed C-extension or built-in module
Run Code Online (Sandbox Code Playgroud)
和想法¿?
服务器中的查询字典是 <QueryDict: {u'{"id":"xxx","jsonrpc":"2.0","method":"XXX","params":{...}}': [u'']}>
正如你可以检查django处理程序解析POST请求的json作为新字典的键...
在链接问题中,有下一个解决方案......
hack_json_value = request.POST.keys()[0]
hack_query_dict = json.loads(hack_json_value)
foo = hack_query_dict['foo']
bar = hack_query_dict['bar']
Run Code Online (Sandbox Code Playgroud)
但也许你可以帮我找另一个...... …
我们的iPad版本存在下一个问题.
我在UITabBar中有一个NavigationController.我希望显示一个外观和感觉类似于电子邮件表单的表单.
我使用相同的代码来显示模型居中:
// View to be displayed in the modal
AdhocViewController *controller = [[AdhocViewController alloc] initWithNibName:@"AdhocViewController" bundle:[NSBundle mainBundle]];
controller.caller = self;
// The form will need a navigation bar to cancel or save the form
UINavigationController *modalViewNavController = [[UINavigationController alloc]
initWithRootViewController:controller];
// Configurate the modal presentation and transition
modalViewNavController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
modalViewNavController.modalPresentationStyle = UIModalPresentationFormSheet;
// Show the new view
[self presentModalViewController:modalViewNavController animated:YES];
Run Code Online (Sandbox Code Playgroud)
此代码在纵向模式下完美运行,但在横向上,视图部分显示在屏幕外...我还没有找到解决它的方法.
我测试了一些我在这里找到的解决方案......
并在预设模型视图后尝试添加下一行以调整其大小,但不能解决问题
controller.view.superview.frame = CGRectMake(0, 0, 600, 700);
controller.view.superview.center = self.view.center;
Run Code Online (Sandbox Code Playgroud)
有什么建议吗?
谢谢,
伊万
StackOverflow中的引用:
objective-c ipad modalviewcontroller uimodalpresentationstyle
我们正在努力实现IOS6和IOS7之间的转换,并且目前还有下一个问题,没有解决方案:
我们的观点结构是下一个:
完美地使用以前版本的IOS SDK.
但是在IOS7中我们遇到了下一个麻烦:
有什么建议?