gpt4 book ai didi

ios - 如何使用 Swift 打印 DynamoDB 查询结果

转载 作者:行者123 更新时间:2023-11-28 06:43:53 25 4
gpt4 key购买 nike

在对 DynamoDB 表进行查询后,我试图打印查询结果。稍后我会在表格中显示它,但现在我只想确保它正常工作。查询有效并且没有任何错误。我认为它与我不理解的分页功能有关。我尝试阅读文档,但对我没有帮助。

 func queryWithPartitionKeyAndSortKeyAndFilterWithCompletionHandler(completionHandler: (response: AWSDynamoDBPaginatedOutput?, error: NSError?) -> Void) {
let objectMapper = AWSDynamoDBObjectMapper.defaultDynamoDBObjectMapper()
let queryExpression = AWSDynamoDBQueryExpression()

queryExpression.keyConditionExpression = "#userId = :userId AND #genre < :genre"
queryExpression.filterExpression = "#author > :author"
queryExpression.expressionAttributeNames = [
"#userId": "userId",
"#genre": "genre",
"#author": "author",
]
queryExpression.expressionAttributeValues = [
":userId": AWSIdentityManager.defaultIdentityManager().identityId!,
":genre": "fiction",
":author": "Taylor",
]

objectMapper.query(Books.self, expression: queryExpression, completionHandler: {(response: AWSDynamoDBPaginatedOutput?, error: NSError?) -> Void in
dispatch_async(dispatch_get_main_queue(), {
completionHandler(response: response, error: error)
})
})
}


let completionHandler = {(response: AWSDynamoDBPaginatedOutput?, error: NSError?) -> Void in
if let error = error {
var errorMessage = "Failed to retrieve items. \(error.localizedDescription)"
if (error.domain == AWSServiceErrorDomain && error.code == AWSServiceErrorType.AccessDeniedException.rawValue) {
errorMessage = "Access denied. You are not allowed to perform this operation."
}
}else {


print("I did it" )
print(response)


}
}

最佳答案

AWSDynamoDBPaginatedOutput 有一个名为 items 的属性.您应该打印出数组的内容。

关于ios - 如何使用 Swift 打印 DynamoDB 查询结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37093739/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com