You are currently viewing DynamoDB API – Part Two

DynamoDB API – Part Two

DynamoDB API – Part Two

Hello Everyone

Welcome to CloudAffaire and this is Debjeet

In the last blog post, we have discussed some of the DynamoDB API’s available.

https://cloudaffaire.com/dynamodb-api-part-one/

In this blog post, we are going to continue our discussion on basic API’s available in DynamicDB.

DynamoDB API

UpdateItem:

Edits an existing item’s attributes, or adds a new item to the table if it does not already exist. You can put, delete, or add attribute values. You can also perform a conditional update on an existing item (insert a new attribute name-value pair if it doesn’t exist, or replace an existing name-value pair if it has certain expected attribute values).

Syntax:

Example: We will add a name (Bob) and salary (1200) where id = 100 in Employee table

key1.json

key2.json

key3.json

DynamoDB API

GetItem:

The GetItem operation returns a set of attributes for the item with the given primary key. If there is no matching item, GetItem does not return any data and there will be no Item element in the response.

Syntax:

Example: We will fetch all details where id = 100 from Employee table

key4.json

DynamoDB API

BatchGetItem:

The BatchGetItem operation returns the attributes of one or more items from one or more tables. You identify requested items by primary key. A single operation can retrieve up to 16 MB of data, which can contain as many as 100 items. BatchGetItem will return a partial result if the response size limit is exceeded, the table’s provisioned throughput is exceeded, or an internal processing failure occurs. If a partial result is returned, the operation returns a value for UnprocessedKeys. You can use this value to retry the operation starting with the next item to get.

Syntax:

Example: We will fetch all details where id = 101 and 104 from Employee table

key5.json

DynamoDB API

Query:

The Query operation finds items based on primary key values. You can query any table or secondary index that has a composite primary key (a partition key and a sort key).

Syntax:

Example: We will fetch salary details where id = 101 from Employee table

key6.json

DynamoDB API

DeleteItem:

Deletes a single item in a table by primary key. You can perform a conditional delete operation that deletes the item if it exists, or if it has an expected attribute value.

Syntax:

Example: We will data where id = 104 from Employee table

key7.json

DynamoDB API

DeleteTable:

The DeleteTable operation deletes a table and all of its items. After a DeleteTable request, the specified table is in the DELETING state until DynamoDB completes the deletion. If the table is in the ACTIVE state, you can delete it. If a table is in CREATING or UPDATING states, then DynamoDB returns a ResourceInUseException. If the specified table does not exist, DynamoDB returns a ResourceNotFoundException. If the table is already in the DELETING state, no error is returned.

Syntax:

Example: We will the Employee table

DynamoDB API

Hope you have enjoyed this article. Stream API is not covered in this blog and will be covered when we will discuss features of DynamoDB. In the next blog post, we will discuss Primary Key in DynamoDB.

To get more details on DynamoDB, please refer below AWS documentation

https://docs.aws.amazon.com/dynamodb/index.html

 

This Post Has One Comment

  1. Avatar
    go to website

    Your topic seems somewhat terse-you’re often incredibly eloquent in your reasoning.

Comments are closed.