Declare a TypeScript class to be represent items in a table in a way
understandable by the AWS DynamoDB DataMapper for JavaScript. Meant to be
used as a TypeScript class decorator in projects compiled with the
experimentalDecorators
option enabled.
Declare a property in a TypeScript class to be part of a DynamoDB schema. Meant to be used as a property decorator in conjunction with TypeScript's emitted type metadata. If used with in a project compiled with the
emitDecoratorMetadata
option enabled, the type will infer most types from the TypeScript source.Please note that TypeScript does not emit any metadata about the type parameters supplied to generic types, so
Array<string>
,[number, string]
, andMyClass[]
are all exposed asArray
via the emitted metadata. Without additional metadata, this annotation will treat all encountered arrays as collections of untyped data. You may supply either amembers
declaration or amemberType
declaration to direct this annotation to treat a property as a tuple or typed list, respectively.Member type declarations are required for maps and sets.
https://www.typescriptlang.org/docs/handbook/decorators.html
https://www.typescriptlang.org/docs/handbook/compiler-options.html
https://github.com/Microsoft/TypeScript/issues/2577
export class MyClass { @attribute() id: string;
@attribute() subdocument?: MyOtherClass; @attribute() untypedCollection?: Array<any>; @attribute({memberType: {type: 'String'}}) listOfStrings?: Array<string>; @attribute({members: [{type: 'Boolean', type: 'String'}]}) tuple?: [boolean, string]; @attribute({memberType: {type: 'String'}}) mapStringString?: Map<string, string>; @attribute() binary?: Uint8Array;
}