Chapter 6: Expressions

Expressions are statements that operate on your items. They’re sort of like mini- SQL statements.

There are five types of expressions in DynamoDB:

1: Key Condition Expressions: Used in the Query API call to describe which items you want to retrieve in your query

2: Filter Expressions: Used in Query and Scan operations to describe which items should be returned to the client after finding items that match your key condition expression

3: Projection Expressions: Used in all read operations to describe which attributes you want to return on items that were read

4: Condition Expressions: Used in write operations to assert the existing condition (or non-condition) of an item before writing to it

5: Update Expressions: Used in the UpdateItem call to describe the desired updates to an existing item

The first three expressions are for read-based operations. The fourth, Condition Expressions, is for all write-based operations, and the last, Update Expressions, is for update operations only.

In order to learn all the expressions in this chapter, we will assume that we are a business owner who needs to keep a track of all the customers. As the business owner we will be able to create, read, update and delete our customer data. So lets add a few customers before we proceed with the sub-sections in this chapter.

We will store each customer details in our dynamodb table. We will set the partition key(pk) as "CUSTOMERS" and we will set the sort key(sk) as "CUSTOMER#<PhoneNumber>", since phone numbers are unique to each customer, it seems like the right fit for the sort key.

Fill in the details and click the "Add Customer" button. The customer will get saved in your DynamoDB table.

For the customer to get saved in your table, you must complete the steps in requirements chapter.

Shipping address