Dynamoose TypeScript ValidationException:使用 .get() 时键上的条件数无效

问题描述

给定以下用于创建表的 dynamodb 架构:

  "KeySchema": [
    {
      "AttributeName": "id","KeyType": "HASH"
    },{
      "AttributeName": "name","KeyType": "RANGE"
    }
  ],

代码中的动态模式:

new dynamoose.Schema({
  id: {
    type: String,},name: {
    type: String,

在使用 ValidationException: The number of conditions on the keys is invalid 时看到 repository.get() 错误

解决方法

解决办法:需要在dynamoose schema中指定range key。

  id: {
    type: String,hashKey: true,},name: {
    type: String,rangeKey: true,