Skip to content

Commit

Permalink
added IndexName support to queryBeginsWith() method
Browse files Browse the repository at this point in the history
  • Loading branch information
mfriesen committed Jul 31, 2023
1 parent 1f88cd5 commit 5a590bc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,11 @@ public QueryResponse queryBeginsWith(final QueryConfig config, final AttributeVa

Map<String, AttributeValue> values = Map.of(":pk", pk, ":sk", sk);

QueryRequest q = QueryRequest.builder().tableName(this.tableName)
.keyConditionExpression(expression).expressionAttributeValues(values)
.scanIndexForward(Boolean.FALSE).projectionExpression(config.projectionExpression())
.exclusiveStartKey(exclusiveStartKey).limit(Integer.valueOf(limit)).build();
QueryRequest q =
QueryRequest.builder().tableName(this.tableName).keyConditionExpression(expression)
.expressionAttributeValues(values).scanIndexForward(Boolean.FALSE)
.projectionExpression(config.projectionExpression()).indexName(config.indexName())
.exclusiveStartKey(exclusiveStartKey).limit(Integer.valueOf(limit)).build();

QueryResponse response = this.dbClient.query(q);
return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class QueryConfig {

/** {@link Map}. */
private Map<String, String> expressionAttributeNames;
/** Index Name. */
private String indexName;
/** Projection Expression. */
private String projectionExpression;

Expand Down Expand Up @@ -64,6 +66,26 @@ public QueryConfig expressionAttributeNames(final Map<String, String> expression
return this;
}

/**
* Get Index Name.
*
* @return {@link String}
*/
public String indexName() {
return this.indexName;
}

/**
* Set Index Name.
*
* @param index {@link String}
* @return {@link QueryConfig}
*/
public QueryConfig indexName(final String index) {
this.indexName = index;
return this;
}

/**
* Get Projection Expression.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public FolderIndexRecord path(final String documentPath) {
@Override
public String pk(final String siteId) {
checkParentId();
return SiteIdKeyGenerator.createS3Key(siteId,
return SiteIdKeyGenerator.createDatabaseKey(siteId,
GLOBAL_FOLDER_METADATA + TAG_DELIMINATOR + this.parentDocumentId);
}

Expand Down

0 comments on commit 5a590bc

Please sign in to comment.