在dynamodb中使用batchWriteItem

编程入门 行业动态 更新时间:2024-10-23 21:37:10
本文介绍了在dynamodb中使用batchWriteItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的dynamo数据库中有两个表,一个是候选表,另一个是用户表,我想在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

本文发布于:2023-11-28 07:43:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641521.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:dynamodb   batchWriteItem

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!