Using batchWriteItem in dynamodb(在 dynamodb 中使用 batchWriteItem)
问题描述
我的 dynamo db 中有两个表,一个是候选表,另一个是用户表,我想在 dynamo db 中使用 batchWriteItem 以便在表中添加数据.
I have two tables in my dynamo db one is candidate table and the other one is user table I want to use batchWriteItem in dynamo db in order to add the data in the table.
我格式化的查询如下
var user = {
userid: usrid,
role: 'candidate',
password: vucrypt.encryptpass(pass)
};
var canduser = {
fname: req.body.fname,
lname: req.body.lname,
location: req.body.location,
phone: req.body.phone,
ccode: req.body.ccode,
grad: req.body.grad,
pgrad: req.body.pgrad,
ograd: req.body.ograd,
experience: exp,
linkedin: req.body.linkedin,
terms: tandc
};
canduser = vutools.fixcanduser(canduser);
canduser.userid = usrid;
var writes = {
'users': [{put: user}],
'candidate': [{put: canduser}],
};
但是如果我使用dynamodb.batchWriteItem(writes, function(err, regdata) {}
它以错误告终.如何编写正确的查询?我得到的错误是这样的.
Its ending up as error. How can I write the right query? The error I am getting is this.
MultipleValidationErrors: There were 3 validation errors:
* MissingRequiredParameter: Missing required key 'RequestItems' in params
* UnexpectedParameter: Unexpected key 'users' found in params
* UnexpectedParameter: Unexpected key 'candidate' found in params
推荐答案
这是正确的答案有一些类型问题.
This is the right answer there are some type problems.
var createuser = {
"RequestItems": {
"users": [{
"PutRequest": {
Item: {
"userid": {
"S": usrid +""
},
"password": {
"S": vucrypt.encryptpass(pass) +""
},
"role": {
"S": 'candidate' +""
}
}
}
}],
"candidate": [{
"PutRequest": {
Item: {
"ccode": {
"S": req.body.ccode +""
},
"fname": {
"S": req.body.fname +""
},
"lname": {
"S": req.body.lname +""
},
"pgrad": {
"S": req.body.pgrad +""
},
"videoresumeurl": {
"S": "-"
},
"phone": {
"S": req.body.phone +""
},
"terms": {
"S": tandc +""
},
"location": {
"S": req.body.location +""
},
"experience": {
"N": req.body.experience +""
},
"userid": {
"S": usrid +""
},
"grad": {
"S": req.body.grad +""
}
}
}
}]
}
}
这篇关于在 dynamodb 中使用 batchWriteItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 dynamodb 中使用 batchWriteItem
基础教程推荐
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 直接将值设置为滑块 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01