Example usage for com.amazonaws.services.dynamodbv2.model QueryRequest addKeyConditionsEntry

List of usage examples for com.amazonaws.services.dynamodbv2.model QueryRequest addKeyConditionsEntry

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.model QueryRequest addKeyConditionsEntry.

Prototype

public QueryRequest addKeyConditionsEntry(String key, Condition value) 

Source Link

Usage

From source file:awslabs.lab22.SolutionCode.java

License:Open Source License

@Override
public QueryResult lookupByHashKey(AmazonDynamoDBClient ddbClient, String tableName, String company) {
    // Construct an AttributeValue object containing the provided company name.
    AttributeValue attributeValue = new AttributeValue().withS(company);
    // Construct a Condition object containing the desired comparison ("EQ") and the attribute value
    // containing the company name.
    Condition condition = new Condition().withComparisonOperator("EQ").withAttributeValueList(attributeValue);

    // Construct a QueryRequest object that performs a consistent read on the specified table for the
    // previously constructed condition.
    QueryRequest queryRequest = new QueryRequest().withTableName(tableName).withConsistentRead(true);
    queryRequest.addKeyConditionsEntry("Company", condition);

    // Submit the query by calling the query method of the ddbClient object and return the result.
    return ddbClient.query(queryRequest);
}

From source file:awslabs.lab51.SolutionCode.java

License:Open Source License

@Override
public Boolean isImageInDynamo(AmazonDynamoDBClient dynamoDbClient, String tableName, String key) {
    QueryRequest queryRequest = new QueryRequest(tableName).withConsistentRead(true);
    queryRequest.addKeyConditionsEntry("Key",
            new Condition().withComparisonOperator("EQ").withAttributeValueList(new AttributeValue(key)));

    return (dynamoDbClient.query(queryRequest).getCount() > 0);
}