Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Order of insertion of array values at Amazon DynamoDB

When adding an array at DynamoDB with put_item, is there any way to tell it to preserve the order of the values of the array?

Example: I'm adding array("2", "1", "4"), and it's added to the table as 1, 2, 4. I don't want dynamo to mess up with my array :)

Thanks in advance.

like image 845
DMerliMorais Avatar asked Oct 13 '25 06:10

DMerliMorais


2 Answers

No, as arrays in dynamoDB are Sets, they don't preserve any ordering.

best alternative for you is to concatenate them into a string (using a delimiter) and then inserting this string i.e. 2#1#4 and then split them when you read back.

like image 174
Ashwin Patti Avatar answered Oct 14 '25 22:10

Ashwin Patti


No. Although you use PHP arrays when inserting values, DynamoDB doesn't actually support arrays. Instead it offers sets, which don't have any ordering and don't allow duplicate values.

like image 34
pw. Avatar answered Oct 14 '25 20:10

pw.