我开始了一个新的TypeScript / Node项目,该项目将具有DynamoDB后端,并且我试图使用DynamoDB数据映射器,但是出现以下错误:
提供的项目不符合DynamoDbDocument协议。没有 在
DynamoDbSchema
符号处找到了对象属性。
我试图同时使用注释和直接在类原型上设置模式的方法,但是它们都导致相同的错误,这使我相信我的问题与某种配置有关。这是我的tsconfig.json:
{
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"sourceMap": true,
"moduleResolution": "node",
"outDir": "dist",
"rootDir": "./",
"types": ["reflect-metadata"],
"lib": ["es2017", "esnext.asynciterable"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true
},
"include": [
"src/**/*"
]
}
这是模型:
import Employee from "./Employee";
import {Location} from "./Location";
import {attribute, hashKey, table} from "@aws/dynamodb-data-mapper-annotations";
@table('mentors')
export default class Mentor implements Employee {
@attribute()
name: string;
@hashKey()
username: string;
@attribute()
email: string;
@attribute()
title: string;
@attribute()
team: string;
@attribute()
location: Location;
@attribute({memberType: 'String'})
areasOfInterest: Set<string>;
@attribute({memberType: 'String'})
willMentorLocations: Set<string>;
@attribute({memberType: 'String'})
mentees: Set<string>;
}
以下是相关的依赖版本:
"@aws/dynamodb-data-mapper": "^0.7.3",
"@aws/dynamodb-data-mapper-annotations": "^0.7.3",
"reflect-metadata": "^0.1.12",
"typescript": "^3.1.6"