# DynamoDB Request

The DynamoDB Request allows you to execute multiple operations on DynamoDB-compatible data sources.

You can use UI Bakery variables to compose table names, item keys, and filter expressions. Here's an example of a *dynamic update expression*:

```javascript
{
  "TableName": "users",
    "Key": {
    "Id": {
      "N": "101"
    }
  },
  "UpdateExpression": "SET Title = :title",
    "ExpressionAttributeValues": {
    ":title": {
      "S": {{ui.input.value}}
    }
  }
}
```

## DynamoDB command examples

<figure><img src="/files/RXunwWXVFvvSLp3o2Z3m" alt=""><figcaption></figcaption></figure>

### query

`query` is used to search for or filter the items in your DynamoDB collection. Select `query` from the list and specify its parameters:

```javascript
{
  TableName: 'users',
  KeyConditionExpression: "Id = :v1",
  ExpressionAttributeValues: {
    ':v1': {"N": '101'},
  }
}
```

### scan

`scan` is used to retrieve all of the items or just some of them from your DynamoDB collection. Select `scan` from the list and specify the query parameters:

```javascript
{
	TableName: 'users',
}
```

### getItem

The `getItem` operation returns a set of `Attributes` for an item that matches the primary key. Select `getItem` from the list and specify the query parameters:

```javascript
{
  TableName: 'users',
  Key: {
    Id: {
      N: '101'
    }
  }
}
```

### putItem

To add a new item to your collection, use `putItem`. Select `putItem` from the list and specify the query parameters:

```javascript
{
  "TableName": "users",
  "Item": {
    "Id": {
        "N": "110"
    },
    "username": {
        "S": "JohnDoe"
    },
    "email": {
        "S": "johndoe@example.com"
    },
    "age": {
        "N": "30"
    },
    "gender": {
        "S": "male"
    }
  }
}
```

### updateItem

`updateItem` edits an existing item's attributes or adds a new item to the table if it doesn't exist yet. You can put, delete, or add attribute values. Select `updateItem` from the list and specify the query parameters:

```javascript
{
  "TableName": "users",
  "Key": {
    "Id": {
      "N": "101"
    }
  },
  "UpdateExpression": "SET Title = :title",
  "ExpressionAttributeValues": {
    ":title": {
      "S": {{ui.input.value}}
    }
  }
}
```

### deleteItem

To delete an item from the collection, use `deleteItem`. Select `deleteItem` from the list and specify the query parameters:

```javascript
{
  "TableName": "users",
  "Key": {
    "Id": {
      "N": "101"
    }
  }
```

### batchWriteItem

To put or delete multiple items in one or more collections, use `batchWriteItem`. Select `batchWriteItem` from the list and specify the query parameters:

```javascript
{
  "RequestItems": {
    "users": [
      {
        "PutRequest": {
          "Item": {
            "Id": {
              "N": "110"
            },
            "username": {
              "S": "JohnDoe"
            },
            "email": {
              "S": "johndoe@example.com"
            },
            "age": {
              "N": "30"
            },
            "gender": {
              "S": "male"
            }
          }
        }
      }
    ]
  }
}
```

For more details about DynamoDB queries, please refer to [DynamoDB docs](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithDynamo.html).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.uibakery.io/reference/working-with-actions/dynamodb-request.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
