本文介绍了Dynamo数据库类型转换错误ValidationException:提供的值无法转换为数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个这样的发电机数据库查询。我执行的将数据添加到两个不同的表中,而这个问题是第一个问题的继续。
I have a dynamo DB query like this. Which I execute to add data to two different table and this question is the continuation of the first question. 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
}
}
}
}
]
}
}
当我将此代码删除时我收到这样的错误。
When i excicute this code i am getting an error like this.
ValidationException: A value provided cannot be converted into a number
我尝试过这个。
var exps = Number(exp);
但是,此错误仍然存在,我该怎么办?知道吗?
But still, this error persist what can I do? any idea?
我的代码是这样的。
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.');
});
推荐答案
所有值都必须为字符串:
All the values must be strings:
例如:
"fname": {
"S": req.body.fname
}
,所以只需添加
req.body.fname + ""
OR
这篇关于Dynamo数据库类型转换错误ValidationException:提供的值无法转换为数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!