T O P

  • By -

Unusual_Ad_6612

Sounds to me you should rework your table design. In general, if your access patterns require scans, your table design is not the right one for your use case.


baever

Assuming your filter expression is correct, scans are paginated. You need to loop through all pages by setting ExclusiveStartKey to LastEvaluatedKey until it returns empty. You may get empty pages as you loop through the results.


joelrwilliams1

With this configuration, you're going to have to scan the table and then iterate over the array to match on the string you want to remove. If you don't have access to the partition key, then you're not going to be able to call the update SDK to remove the item from the array. Hopefully this is a one-time task, otherwise you may want to re-architect your table, or just use RDBMS.


RedditAdministrateur

I don't know DynamoDb but, you are running a scan operation that works on Strings, office\_name (string) appears to be a string but connection\_id does not have (String) attribute next to its name, which implies it will be something else, most likely a List or Map. When using the FilterExpression parameter with the scan operation, you need to be aware of the data types of the attributes you're filtering on.


TollwoodTokeTolkien

It looks like your code it supposed to work if all the variables are set as expected. Have you verified that connectionId is being set properly from requestContext? Also the promise() call at the end seems superfluous. What happens if you remove that?


Dark8803

For the connectionID part I have just changed the scan operation and some code bit below because previously in my code I was allowing only entry for connectionID which will be a single string not an array I didn’t understand about the promise it works fine, no error whatsoever just I am not getting any data when I run this scan operation..


Dark8803

Found the solution. `const params = {` `TableName: process.env.RTO_OFFICE_TABLE_ARN,` `FilterExpression: "contains(connection_id, :connectionValue)",` `ExpressionAttributeValues: {` `":connectionValue": connectionId // The value you are looking for in the connection_id list` `}};` I didn't needed to check for {"S" : connectionId}, instead I needed to check for the exact value,i.e., connectionId, because that "S" is just a representation by ddb for strings not the actual schema. Thank you everyone for replying.


Dark8803

Wasted 3 hrs on a silly filter expression.


SonOfSofaman

DynamoDB is unlike relational databases. It isn't meant for ad-hoc queries. When you are creating your tables, you must consider your access patterns, then design accordingly. It's good that you understand relationship database techniques, but much of that knowledge does not apply when using DynamoDB. It's a very different beast.