Problem gelöst: Modelleigenschaften enthalten Großbuchstaben. Wenn Sie sie entfernen, funktioniert der Prozess.
Nachfolgend wird der nicht funktionierende Code dargestellt. Im Projekt muss der Feldname in DynamoDB mit einem Großbuchstaben beginnen. Ich habe dann nach dieser Regel Eigenschaften mit einem zusätzlichen Präfix-Unterstrich erstellt.
class MyModel: AWSDynamoDBObjectModel, AWSDynamoDBModeling {
var _UserId: String?
var _ArticleId: String?
class func dynamoDBTableName() -> String {
return "myTable"
}
class func hashKeyAttribute() -> String {
return "_UserId"
}
class func rangeKeyAttribute() -> String {
return "_ArticleId"
}
override class func JSONKeyPathsByPropertyKey() -> [NSObject : AnyObject] {
return [
"_UserId" : "UserId",
"_ArticleId" : "ArticleId",
]
}
}
Jahr Dies ist der Arbeitscode:
class MyModel: AWSDynamoDBObjectModel, AWSDynamoDBModeling {
var _userId: String?
var _articleId: String?
class func dynamoDBTableName() -> String {
return "myTable"
}
class func hashKeyAttribute() -> String {
return "_userId"
}
class func rangeKeyAttribute() -> String {
return "_articleId"
}
override class func JSONKeyPathsByPropertyKey() -> [NSObject : AnyObject] {
return [
"_userId" : "UserId",
"_articleId" : "ArticleId",
]
}
}
Seltsam, nicht wahr?