Closed ostmond closed 2 years ago
Your text is malformed in markdown but i guess what you meant is
export class BlogPost extends Table {
...
@Decorator.Attribute({ name: "body" })
public body: Array<Text>
...
}
export class Text {
type: "text",
text: string
}
Short answer is yes. DynamoDB itself supports all primitive types that is JSON compatible as long as you only use those, (object, array, number, string, boolean) it works.
Long answer is, but you should not use "class"
export interface Text {
type: "text",
text: string
}
"Interface" is purely typescript definition so doesn't matter, but "class" is 1) runtime definition, 2) typescript definition. DynamoDB (or Dynamorm) doesn't have feature of serialize / deserialize class object. thus this will cause problem.
Does dynamorm support typed object in TypeScript? For example:
export class BlogPost extends Table { ... @Decorator.Attribute({ name: "body" }) public body: Array
...
}
And then in the text.ts export class Text { type: "text", text: string }
I think it would be better than JS anonym object.