我有一个像这样的发电机数据库查询。我执行该操作以将数据添加到两个不同的表中,这个问题是第一个问题的延续。 Using batchWriteItem in dynamodb
var createuser = {
"RequestItems": {
"users": [
{
"PutRequest": {
Item: {
"userid": { "N": "usrid" },
"role": { "S": 'candidate' },
"password": { "S": vucrypt.encryptpass(pass) }
}
}
}
],
"candidate": [
{
"PutRequest": {
Item: {
"fname": {
"S": req.body.fname
},
"lname": {
"S": req.body.lname
},
"location": {
"S": req.body.location
},
"phone": {
"S": req.body.phone
},
"ccode": {
"S": req.body.ccode
},
"grad": {
"S": req.body.grad
},
"pgrad": {
"S": req.body.pgrad
},
"ograd": {
"S": req.body.ograd
},
"experience": {
"N": "10"
},
"linkedin": {
"S": req.body.linkedin
},
"terms": {
"S": tandc
}
}
}
}
]
}
}
当我执行这段代码时,我收到这样的错误。
ValidationException: A value provided cannot be converted into a number
我尝试过这个。
var exps = Number(exp);
但是这个错误仍然存在,我该怎么办?有什么想法吗?
我的代码是这样的。
dynamodb.batchWriteItem(createuser, function(err, regdata) {
vulog.debug(regdata);
if (err || !regdata || regdata.Responses.UnprocessedItems) {
vulog.warn('ddb: error in checking corp user details1 \n' + err);
res.send(400, 'Unable to register at present, please try later');
return;
}
vulog.debug('Candidate added successful');
res.send(200, 'Success! Your account has been created.\n Check your email for further instructions.');
});
最佳答案
所有值必须是字符串:
例如:
"fname": {
"S": req.body.fname
}
req.body.fname must be a string
所以只需添加
req.body.fname + ""
或者
req.body.fname.toString();
关于javascript - Dynamo 数据库类型转换错误 ValidationException : A value provided cannot be converted into a number,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51705330/