-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathorder.js
37 lines (34 loc) · 831 Bytes
/
order.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
console.log('Loading function');
var doc = require('dynamodb-doc');
var db = new doc.DynamoDB();
exports.handler = function(event, context,callback)
{
var id=event.id;
var email = event.email;
var itemList = event.itemList;
var totalPrice=event.totalPrice;
console.log(email + "," + itemList+ ","+ totalPrice );
var tableName = "order";
var item = {
"oid":id,
"email": email,
"itemList": itemList,
"totalPrice":totalPrice
};
var params = {
TableName:tableName,
Item: item
};
console.log(params);
var flag=false;
db.putItem(params,function(err,data){
if (err) {console.log("fail");console.log(err);
callback(null,flag);
}
else{ console.log("success");
console.log(data);
flag=true;
callback(null,flag);
}
});
};