How can I save a StringSet value in DynamoDb?

Hi, I'm trying to save a field with a StringSet type.
I see that your marshalling function transforms an array of strings always into a list but I need it as a String set.

My Input:
{ listOfStrings: ['a', 'b', 'c'] }

Desired Output:
{ "listOfStrings": { "SS" : ["a", "b", "c"] } }

Current Output:
{ "listOfStrings": { "L" : [ {"S": "a"}, {"S": "b"}, {"S": "c"}] } }

Any workaround I can try?

Thanks
G.

Hi @gtron! Thanks for posting. Could you share a screenshot or screen recording of how you're setting this up? This will give me a better understanding of how I can help. :slightly_smiling_face:

I have the same need - to set a string set to a DynamoDB.

Based on the Retool docs, the editor uses the DynamoDB Document client API. On the following page, it is described how the document client supports creating sets

Support for Sets
The DocumentClient offers a convenient way to create sets from JavaScript Arrays. The type of set is inferred from the first element in the array. DynamoDB supports string, number, and binary sets. To learn more about supported types see the Amazon DynamoDB Data Model Documentation For more information see createSet()

Here is the link to that createSet() function.

The issue I have is that the current saving of a string list results in the following JSON below - an object list basically. I'm saving a list of US states. Notice that the type is also in the list. This is because just saving of a list is occurring so DynamoDB assigns the type to the value - allows a mixed type list. However, this makes working with that list very cumbersome - particularly if the list is of the same type, here all strings.

[ { "S" : "NY" }, { "S" : "FL" }, { "S" : "GA" } ]

My sense is that this is not a currently supported feature - to allow saving same type lists without the type as a qualifier, but I think it would be a really useful change. The CreateSet allows for validation, so maybe always set to true "under the covers".

However, please advise if there is some way to same lists of the same type - string, number in particular - without saving the list as an object list.

Also, thank you for having this interface in the first place! Overall, it has worked well so far.

1 Like

Hi @steve.kumbsky

Thanks for sharing all of these details!

I did some digging internally. It looks like we had one user running into something similar, and they are able to get around it by adding this library to their Retool app:
https://cdnjs.cloudflare.com/ajax/libs/aws-sdk/2.1397.0/aws-sdk.min.js
which allowed them to use the 'createSet()' method :crossed_fingers: Hope it helps!

1 Like

Thanks for the reply and JS library reference from AWS! I will attempt to use and post back with results.