1

I am having trouble with forming a query which can query a given batch of IDs to DynamoDB.

My model is :

@DynamoDBTable(tableName = "person_detail")
data class PersonDetail constructor(
    @DynamoDBHashKey(attributeName = "person_id")
    var personId: Long,
    @DynamoDBRangeKey(attributeName = "phone_number")
    var phoneNumber: String,
    @DynamoDBAttribute(attributeName = "other_attribute")
    var otherAttribute: String,
)

What I am expected to store here is a typical one-to-many relation in RDBMS. One person with id 123 can have multiple phone numbers. I am trying to store them in different rows. The query I am trying to form is given a collection of IDs, I need to find all their details.

What I could solve is given one ID, I can find its details using this:

    return dynamoDBMapper.query(
        PersonDetail::class.java,
        DynamoDBQueryExpression<PersonDetail>().apply {
            hashKeyValues = PersonDetail(id)
        }
    ).toList()

I am struggling to figure out the right API to use so that I can change this so that instead of passing one id at a time I can pass multiple ids at once. Can you please help me with this?

Thank you.

NewUser
  • 3,729
  • 10
  • 57
  • 79

0 Answers0