如何调试ValidationException:所需键之一未赋予值DYnamo db node js

时间:2018-10-09 09:35:02

标签: node.js json amazon-web-services amazon-dynamodb

我正在尝试在dynamo数据库中执行此查询,但是它一直在向我抛出一个错误One of the required keys was not given a value 我要执行的查询是这个。

        var repass = {
          TableName : 'jobcode',
          Key : {
              'jobcodeid': {
                "S":req.session.user.name
              },
              'userid' :{
                "S":req.session.user.name
              }
          },
            UpdateExpression: "set hiringid = :hiringid",
            ExpressionAttributeValues:{
                ":hiringid": {
                  "S": "xxxxx@amazon.com"
                }
            }
        }

我认为问题出在查询上,所以我删除了一个值,查询变成了这样,

        var repass = {
          TableName : 'jobcode',
          Key : {
              'jobcodeid': {
                "S":req.session.user.name
              }
          },
            UpdateExpression: "set hiringid = :hiringid",
            ExpressionAttributeValues:{
                ":hiringid": {
                  "S": "xxxxx@amazon.com"
                }
            }
        }

它给我扔了一个虫子

Conditions in query is invalid

我没有写表和条件,也不知道哪个键是哈希和范围,也不知道是否需要在set属性中添加更多键才能执行此查询。

有什么方法可以调试此问题?

如果我在db中执行扫描操作,这就是我得到的json。

 {
                "hiringid": {
                    "S": "xxxxxx@amazon.com"
                },
                "interviewers": {
                    "S": "rjku@gmail.com"
                },
                "submit": {
                    "N": "0"
                },
                "test": {
                    "N": "0"
                },
                "photo": {
                    "N": "0"
                },
                "title": {
                    "S": "Senior Executive Manager"
                },
                "userid": {
                    "S": "xxxxx@teinfxxxx.com"
                },
                "easy": {
                    "N": "0"
                },
                "hold": {
                    "N": "0"
                },
                "accept": {
                    "N": "0"
                },
                "companyid": {
                    "S": "Tailored Management"
                },
                "jobcodeid": {
                    "S": "JB501"
                },
                "walkin": {
                    "N": "0"
                },
                "reject": {
                    "N": "0"
                },
                "invite": {
                    "N": "1"
                },
                "expiry": {
                    "S": "2015-06-30"
                },
                "live": {
                    "N": "0"
                }
            },

0 个答案:

没有答案