Home Ask Login Register

Developers Planet

Your answer is one click away!

fmog February 2016

aws dynamodb how to use object mapper with batch get in ios

I need to get ~50 items with their primary keys from dynamodb using ios sdk. i am able to get the items by AWSDynamoDB.defaultDynamoDB().batchGetItem but couldn't figure out if it is possible to use object mapper with the response. Unfortunately objectmapper class in ios doesn't have batchGet function. As far as i know i cant use query in this situation.

Is it possible to use object mapper? If not which one makes more sense: parsing the response to get the desired class instance or calling objectMapper.load on each item?


Yosuke Matsuda February 2016

Currently, AWSDynamoDBObjectMapper does not support the batch get item. You need to load one item at a time if you want to use the object mapper.

Niklas March 2016

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] {
        else if let error = task.error {
        return nil

Post Status

Asked in February 2016
Viewed 1,161 times
Voted 9
Answered 2 times


Leave an answer

Quote of the day: live life