Tuesday, June 4, 2024
 Popular · Latest · Hot · Upcoming
116
rated 0 times [  122] [ 6]  / answers: 1 / hits: 18241  / 6 Years ago, mon, august 6, 2018, 12:00:00

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.



The query which I have formatted is as follows



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}],
};


But if i use

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

More From » node.js

 Answers
12

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 +
}
}
}
}]
}
}

[#53803] Wednesday, August 1, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
forrestn

Total Points: 552
Total Questions: 94
Total Answers: 101

Location: Sao Tome and Principe
Member since Thu, Apr 20, 2023
1 Year ago
;