我正在Swift中开发一个应用程序,并将DynamoDB用于我的数据库。
扫描数据库时,当我打印属性时,它们将返回为nil,但是,nil会打印出查询后显示记录的次数。如果我将查询更改为表中没有值的内容,则不会打印任何内容。
我该如何解决这个问题?
这是我的代码:
let credentialsProvider = AWSCognitoCredentialsProvider(regionType:.EUWest2, identityPoolId:"*redacted*")
let configuration = AWSServiceConfiguration(region:.EUWest2, credentialsProvider:credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
let cognitoId = credentialsProvider.identityId
var dynamoDBObjectMapper = AWSDynamoDBObjectMapper.default()
let scanExpression = AWSDynamoDBScanExpression()
scanExpression.indexName = "city2"
scanExpression.filterExpression = "city = :cityName"
scanExpression.expressionAttributeValues = [":cityName": "london"]
dynamoDBObjectMapper.scan(AWSLineStatus.self, expression: scanExpression).continueWith(block: { (task:AWSTask!) -> AnyObject! in
if task.result != nil {
let paginatedOutput = task.result as! AWSDynamoDBPaginatedOutput
print("Items: \(paginatedOutput.items)")
for item in paginatedOutput.items as! [AWSLineStatus] {
print(item.line as Any)
}
if ((task.error) != nil) {
print("Error: \(task.error)")
}
return nil
}
return nil
})
谢谢!