Search code examples
swiftamazon-dynamodbamazon-mobile-hub

How to set DynamoDB Table through mobile hub and Swift?


I'm trying to make a table through mobile hub and Swift like this video below. https://www.youtube.com/watch?v=mvDzfqMk5T4&t=323s

But I don't know which Type of attribute should select for Data type of Swift.

What I want to do is making a table which has items like this Struct's elements and userID.

struct Log:Codable {
var name:String
var dur:Double
var color:Data}

Then the table's row should be like this.

userID    name     dur     color

But this color is Data type, so I can't figure out which type of attribute to pick.

Does anyone can help?

Additionally, this struct is Codable, so are there any ways to deal with DynamoDB and mobile hub by JSON? I'm currently following the video above, but if it possible, that sounds convenient.


Solution

  • You can use Byte data type supported by Amazon DynamoDB. See https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBMapper.DataTypes.html for further information.