1

给定以下用于创建表的 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()

4

1 回答 1

1

解决方法:需要在dynamoose模式中指定范围键。

  id: {
    type: String,
    hashKey: true,
  },
  name: {
    type: String,
    rangeKey: true,
  },
于 2021-03-25T14:48:52.070 回答