AWS SimpleDB 选择表达式 iPhone
我需要为 SimpleDB 构造一个 selectExpression,其中我只想要属性 = 到 X 的项目,按属性 Y 降序排序。到目前为止我所拥有的就是:
NSString *selectExpression = [NSString stringWithFormat:@"select itemName() from `%@`",domainString];
@try {
SimpleDBSelectRequest *selectRequest2 = [[[SimpleDBSelectRequest alloc] initWithSelectExpression:selectExpression] autorelease];
SimpleDBSelectResponse *selectResponse = [[Constants sdb] select:selectRequest2];
if (items == nil) {
items = [[NSMutableArray alloc] initWithCapacity:[selectResponse.items count]];
}
else {
[items removeAllObjects];
}
for (SimpleDBItem *item in selectResponse.items) {
[items addObject:item.name];
}
[items sortUsingSelector:@selector(compare:)];
}
@catch (AmazonServiceException *exception) {
NSLog(@"Exception = %@", exception);
}
我宁愿只选择属性 X by Y 的项目(上面)而不是获取所有项目然后排序。我该如何添加这个?它是放在 selectExpression 字符串中还是其他地方。非常感谢!
I need to construct a selectExpression for SimpleDB where I only want items with attributes = to X, sorted in descending order by attribute Y. All I have so far is this:
NSString *selectExpression = [NSString stringWithFormat:@"select itemName() from `%@`",domainString];
@try {
SimpleDBSelectRequest *selectRequest2 = [[[SimpleDBSelectRequest alloc] initWithSelectExpression:selectExpression] autorelease];
SimpleDBSelectResponse *selectResponse = [[Constants sdb] select:selectRequest2];
if (items == nil) {
items = [[NSMutableArray alloc] initWithCapacity:[selectResponse.items count]];
}
else {
[items removeAllObjects];
}
for (SimpleDBItem *item in selectResponse.items) {
[items addObject:item.name];
}
[items sortUsingSelector:@selector(compare:)];
}
@catch (AmazonServiceException *exception) {
NSLog(@"Exception = %@", exception);
}
I would prefer to only select items (above) with attributes X by Y rather than get all items and then sort. How do I add this? Does it go in the selectExpression string or somewhere else. Many thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个——
Try this out --