Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GSI #236

Open
mamakancha opened this issue Jul 18, 2023 · 0 comments
Open

Update GSI #236

mamakancha opened this issue Jul 18, 2023 · 0 comments
Assignees

Comments

@mamakancha
Copy link
Collaborator

mamakancha commented Jul 18, 2023

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.

@mamakancha mamakancha self-assigned this Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant