AWS DynamoDB Batch Get Request - iOS

后端 未结 3 859
深忆病人
深忆病人 2021-01-03 08:29

I can perform a simple Get request on a singular table within AWS dynamoDB however when I expand it to a Batch Request across multiple tables I continue to get

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-03 09:08

    Since the batch get doesn't map to a class I solved it by doing this instead.

    I solved it by doing this,

        let dynamoDBObjectMapper = AWSDynamoDBObjectMapper.defaultDynamoDBObjectMapper()
        let task1 = dynamoDBObjectMapper.load(User.self, hashKey: "rtP1oQ5DJG", rangeKey: nil)
        let task2 = dynamoDBObjectMapper.load(User.self, hashKey: "dbqb1zyUq1", rangeKey: nil)
    
        AWSTask.init(forCompletionOfAllTasksWithResults: [task1, task2]).continueWithBlock { (task) -> AnyObject? in
            if let users = task.result as? [User] {
                print(users.count)
                print(users[0].firstName)
                print(users[1].firstName)
            }
            else if let error = task.error {
                print(error.localizedDescription)
            }
            return nil
        }
    

提交回复
热议问题