Aws dynamodb how to use mapper object with get in ios package

I need to get ~ 50 elements with their primary keys from dynamodb using ios sdk. I can get items using AWSDynamoDB.defaultDynamoDB (). batchGetItem, but couldn't figure out if the mapper object could be used with the response. Unfortunately, the objectmapper class in ios does not have a batchGet function. As far as I know, I cannot use the query in this situation.

Can I use the mapper object? If not, then what is the point: parsing the response to get the required instance of the class or calling objectMapper.load for each element?

+4
source share
2 answers

AWSDynamoDBObjectMapper . , mapper.

+2

, ,

    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
    }
0

Source: https://habr.com/ru/post/1627596/


All Articles