Dynamoose基础示例抛出Cannot read property 'includes'错误如何解决
错误原因
报错信息:
Cannot read property 'includes' of undefined
报错位置:DocumentRetriever.js 文件的 moveParameterNames 函数内部
该错误由主键字段的多余索引配置触发:
- DynamoDB 表的主键本身默认就是主分区索引,不需要额外通过
index: true声明二级索引 - 你给 id 字段添加的
index: true配置会导致 Dynamoose 内部处理索引参数时读取到未定义的属性,最终抛出该错误 - 同时你初始化 Model 时设置了
create: false,Dynamoose 不会自动创建对应的二级索引,也会加剧配置冲突的问题
解决方案
移除 id 字段配置中的 index: true 即可,修改后的 Schema 代码如下:
const UserSchema = new dynamoose.Schema( { id: { type: String, required: true }, }, { timestamps: true }, );
修改后重新运行代码即可正常完成查询操作。
内容的提问来源于stack exchange,提问作者joe.hart
相关产品推荐
相关产品推荐

