You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 01:36:09