Skip to content

Update GSI #236

@mamakancha

Description

@mamakancha

createdBy-itemType-index is getting used in a single API call which just uses node id as the primary information to be extracted from the GSI.

Code Snippet :

fun getAllNodesWithUserID(userID: String): List<String> {

        val expressionAttributeValues: MutableMap<String, AttributeValue> = HashMap()
        expressionAttributeValues[":createdBy"] = AttributeValue(userID)
        expressionAttributeValues[":itemType"] = AttributeValue("Node")
        expressionAttributeValues[":deleted"] = AttributeValue().withN("1")

        return DynamoDBQueryExpression<Node>().queryWithIndex(
            index = "createdBy-itemType-index", keyConditionExpression = "createdBy = :createdBy  and itemType = :itemType",
            projectionExpression = "PK", expressionAttributeValues = expressionAttributeValues, filterExpression = "deleted <> :deleted"
        ).let { it ->
            mapper.query(Node::class.java, it, dynamoDBMapperConfig).map { node ->
                node.id
            }
        }
    }

So, we don't need every attribute in the GSI.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions