Using DynamoDB step by step
Application Type
Traditional Web

Hi, 

I am trying to build an application that shows data stored in DynamoDB in a data table, then when clicked take the user through to the item to allow them to edit it and submit the change. 

I've followed the documentation on the connector and the below video, but being new to Outsystems I am struggling to get anything working. Is there a step-by-step guide to help me do this? 

https://www.outsystems.com/forums/discussion/70312/new-video-how-to-use-amazon-dynamodb/

Thanks in advance! 

Hi Adrian, thanks for posting the question in the forums (assuming you are the same Adrian Woodrup as the person who commented on the video)


Let me try to help you:

  1. Most important thing is that the way we fetch data is different from a relational model approach. This means that you need to understand the business requirements before even starting to create a table. A bit more on this in this video.
  2. In order to query data in DynamoDB you have to always give the Partition Key and/or Sort Key. Eg: in the video, the partition key is the RequestKey attribute and we don't have a sort key; so we only need to give the name of the partition key.
  3. If you want to return all the data in a table you'll have to use the Scan method which is very resource intensive.
  4. The Query method is best in terms of performance but it always needs the Partition Key and its value. That's why the recorded session in #1 is so important to understand.


For a more concrete example:

Let's say you have a table with all your music collection (which is the get started example in the AWS documentation).

You create the Music table and the ArtistName as the Partition Key for that table.

If you want to get all your music, you use the Scan method (which again, is very resource intensive).

If you want to get the music from Artist Z, you use the Query method. Something along these lines:

  • KeyConditionExpression- "ArtistName = :a" 
    • PartitionKey is ArtistName and we are saying that this key will equal the value in ":a"
  • ExpressionAttributeValues- {":a", {"S": "Elton John"}}
    • :a is Elton John, meaning we want all music where the artist is Elton John


Here's the documentation on how to use the inputs for the Query method: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html


To get a specific record/row from a table, you'll need to use the Item_Get action in the DynamoDBConnector. The Key input parameter should be the result of a JSON Serialize of the helper structures. So for example, if you want to return the Song "Another one Bites the Dust" you'll want to do something like this:

I'm pretty sure you'll have more questions, I just want to keep it simple for now.

Hi @Cristiana Umbelino 

Thank you about your video. Very useful...

But we have a problema when use Query. I don't why but i receve error when i try use

I guess all attribuited is correct or not? Do you can see bellow?

 "id" is my Parition key;

My return is a error: "Invalid FilterExpression: The expression can not be empty;". But FilterExpression is not mandatory!

Do you have any exemple that use Query and that can share with us?

Thank you again.

Hi @Aaron Mukerjee 

have you solved this issue? cause i got the same problem now. could you give some advice?

Hey Jeferson,

The FilterExpression parameter should indeed be optional and as much as I can see there's nothing in the connector's code that makes it mandatory. I can't open Integration Studio right now to check the extension code but I'm guessing that's something in the Query method that is not properly handled.

From what you showed and from what I recall when I was using DynamoDB it seems that you have the correct values for the parameters. I did a few tests and I'm having the same issue which is really weird, that error is not supposed to happen.


While I try to get a glimpse at the code, are you able to open the extension module and check what's missing?

Hi Christian, thanks for the reply!!!

Now I'm using Mac OS, but i'm going to find a Windows one to investigate the code as well.

My first impression was that my parameter might be incorrect, but now with your analysis I will focus on the connector code.

I return here with the results of my investigation.

Thanks.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.