Building API Operations - Amazon DynamoDB

Building API Operations

To use the NoSQL Workbench to build DynamoDB CRUD APIs choose Interface-based operations at the top right corner of the NoSQL Workbench.

Choose Data plane operations drop-down, and then choose the operation that you want to build.

You can perform the following operations in the operation builder.

Get Item

To run or generate code for a Get Item operation, do the following.

  1. Specify the partition key value.

  2. If you want to add a projection expression , do the following:

    1. Choose Projection expression.

    2. Choose the + (plus sign) next to Projection expression.

    3. Specify the Attribute name,.

    
                                Console screenshot showing the GetItem operation
                                    builder.
  3. If you want to generate code, choose Generate code.

    Select your desired language from the displayed tabs. You can now copy this code and use it in your application.

  4. If you want the operation to be run immediately, choose Run.

  5. If you want to save this operation for later use, choose Save operation, then enter a name for your operation and click Save.

For more information about this operation, see PutItem in the Amazon DynamoDB API Reference.

Put Item

To run or generate code for a Put Item operation, do the following.

  1. Specify the partition key value.

  2. Specify the sort key value, if one exists.

  3. If you want to add non-key attributes, do the following:

    1. Choose the + (plus sign) next to Other attributes.

    2. Specify the Attribute name, Type, and Value.

  4. If a condition expression must be satisfied for the Put Item operation to succeed, do the following:

    1. Choose Condition.

    2. Specify the attribute name, comparison operator, attribute type, and attribute value.

    3. If other conditions are needed, choose Condition again.

    For more information, see Condition Expressions.

    
                                Console screenshot showing the PutItem operation
                                    builder.
  5. If you want to generate code, choose Generate code.

    Select your desired language from the displayed tabs. You can now copy this code and use it in your application.

  6. If you want the operation to be run immediately, choose Run.

  7. If you want to save this operation for later use, choose Save operation, then enter a name for your operation and click Save.

For more information about this operation, see PutItem in the Amazon DynamoDB API Reference.

Update Item

To run or generate code for an Update Item operation, do the following:

  1. Enter the partition key value.

  2. Enter the sort key value, if one exists.

  3. In Update expression, choose the expression in the list.

  4. Choose the + (plus sign) for the expression.

  5. Enter the attribute name and attribute value for the selected expression.

  6. If you want to add more expressions, choose another expression in the Update Expression drop-down list, and then select the +.

  7. If a condition expression must be satisfied for the Update Item operation to succeed, do the following:

    1. Choose Condition.

    2. Specify the attribute name, comparison operator, attribute type, and attribute value.

    3. If other conditions are needed, choose Condition again.

    For more information, see Condition Expressions.

    
                                Console screenshot showing the UpdateItem operation
                                    builder.
  8. If you want to generate code, choose Generate code.

    Choose the tab for the language that you want. You can now copy this code and use it in your application.

  9. If you want the operation to be run immediately, choose Run.

  10. If you want to save this operation for later use, choose Save operation, then enter a name for your operation and click Save.

For more information about this operation, see UpdateItem in the Amazon DynamoDB API Reference.

Delete Item

To run or generate code for a Delete Item operation, do the following.

  1. Enter the partition key value.

  2. Enter the sort key value, if one exists.

  3. If a condition expression must be satisfied for the Delete Item operation to succeed, do the following:

    1. Choose Condition.

    2. Specify the attribute name, comparison operator, attribute type, and attribute value.

    3. If other conditions are needed, choose Condition again.

    For more information, see Condition Expressions.

    
                                Console screenshot showing the DeleteItem operation
                                    builder.
  4. If you want to generate code, choose Generate code.

    Choose the tab for the language that you want. You can now copy this code and use it in your application.

  5. If you want the operation to be run immediately, choose Run.

  6. If you want to save this operation for later use, choose Save operation, then enter a name for your operation and click Save.

For more information about this operation, see DeleteItem in the Amazon DynamoDB API Reference.

Query

To run or generate code for a Query operation, do the following.

  1. Specify the partition key value.

  2. If a sort key is needed for the Query operation:

    1. Select Sort key.

    2. Specify the comparison operator, attribute type, and attribute value.

  3. If not all the attributes should be returned with the operation result, select Projection expression.

  4. Choose the + (plus sign).

  5. Enter the attribute to return with the query result.

  6. If more attributes are needed, choose the + .

  7. If a condition expression must be satisfied for the Query operation to succeed, do the following:

    1. Choose Condition.

    2. Specify the attribute name, comparison operator, attribute type, and attribute value.

    3. If other conditions are needed, choose Condition again.

    For more information, see Condition Expressions.

    
                                Console screenshot showing the Query operation
                                    builder.
  8. If you want to generate code, choose Generate code.

    Choose the tab for the language that you want. You can now copy this code and use it in your application.

  9. If you want the operation to be run immediately, choose Run.

  10. If you want to save this operation for later use, choose Save operation, then enter a name for your operation and click Save.

For more information about this operation, see Query in the Amazon DynamoDB API Reference.

Scan

To run or generate code for a Scan operation, do the following.

  1. If not all the attributes should be returned with the operation result, select Projection expression.

  2. Choose the + (plus sign).

  3. Specify the attribute to return with the query result.

  4. If more attributes are needed, choose the + again.

  5. If a condition expression must be satisfied for the scan operation to succeed, do the following:

    1. Choose Condition.

    2. Specify the attribute name, comparison operator, attribute type, and attribute value.

    3. If other conditions are needed, choose Condition again.

    For more information, see Condition Expressions.

  6. If you want to generate code, choose Generate code.

    Choose the tab for the language that you want. You can now copy this code and use it in your application.

  7. If you want the operation to be run immediately, choose Run.

  8. If you want to save this operation for later use, choose Save operation, then enter a name for your operation and click Save.

TransactGetItems

To run or generate code for a TransactGetItems operation, do the following.

  1. Choose the + (plus sign).

  2. Follow the instructions for the Get Item operation.

    When you are done specifying the details of the operation, choose the + (plus sign) if you want to add more operations.

    
                                Console screenshot showing the plus sign button in
                                    transactgetitems operation builder.

    To change the order of actions, choose an action in the list on the left side, and then choose the up or down arrows to move it up or down in the list.

    To delete an action, choose the action in the list, and then choose the Delete (trash can) icon.

  3. If you want to generate code, choose Generate code.

    Choose the tab for the language that you want. You can now copy this code and use it in your application.

  4. If you want the operation to be run immediately, choose Run.

  5. If you want to save this operation for later use, choose Save operation, then enter a name for your operation and click Save.

For more information about transactions, see Amazon DynamoDB Transactions.

TransactWriteItems

To run or generate code for a TransactWriteItems operation, do the following.

  1. In the Actions drop-down list, choose the operation that you want.

    • For DeleteItem, follow the instructions for the Delete Item operation.

    • For PutItem, follow the instructions for the Put Item operation.

    • For UpdateItem, follow the instructions for the Update Item operation.

    When you are done specifying the details of the operation, choose the + button.

    
                                Console screenshot showing the plus sign button in
                                    transactwriteitems operation builder.

    To change the order of actions, choose an action in the list on the left side, and then choose the up or down arrows to move it up or down in the list.

    To delete an action, choose the action in the list, and then choose the Delete (trash can) icon.

    
                                Console screenshot showing the up and down arrows and trash
                                    can buttons in operation builder.
  2. If you want to generate code, choose Generate code.

    Choose the tab for the language that you want. You can now copy this code and use it in your application.

  3. If you want the operation to be run immediately, choose Run.

  4. If you want to save this operation for later use, choose Save operation, then enter a name for your operation and click Save.

For more information about transactions, see Amazon DynamoDB Transactions.