AWS DynamoDB 报错:The provided key element does not match the schema

栏目: 数据库 · 发布时间: 5年前

内容简介:在这个坑上,经历了两次,所以我不得不写篇文章记录一下。起先是因为我只定义了一个 schema:后来,变成了两个:结果在对应的查询参数的 Key 里,漏掉了这部分的内容:

在这个坑上,经历了两次,所以我不得不写篇文章记录一下。起先是因为我只定义了一个 schema:

KeySchema:
          - AttributeName: id
            KeyType: HASH

后来,变成了两个:

KeySchema:
          - AttributeName: id
            KeyType: HASH
          - AttributeName: token
            KeyType: RANGE

结果在对应的查询参数的 Key 里,漏掉了这部分的内容:

Key: {
      id: body.id
    },

导致了:

{ ValidationException: The provided key element does not match the schema
    at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:48:27)
    at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)
    at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
  message: 'The provided key element does not match the schema',
  code: 'ValidationException',
  time: 2019-02-26T12:31:25.507Z,
  requestId: 'POTAMPSSPFSOIU78QM637HK7BNVV4KQNSO5AEMVJF66Q9ASUAAJG',
  statusCode: 400,
  retryable: false,
  retryDelay: 44.331159666822884 } null
END RequestId: 782c2eb3-629e-43e0-b63c-c66678c5590b

下次,记得,加上,加上:

Key: {
    id: body.id,
    token: body.token  // 缺少了这部分的内容
  },

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Tango with Django

Tango with Django

David Maxwell、Leif Azzopardi / Leanpub / 2016-11-12 / USD 19.00

Tango with Django is a beginner's guide to web development using the Python programming language and the popular Django web framework. The book is written in a clear and friendly style teaching you th......一起来看看 《Tango with Django》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具