Newer
Older
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var AWS = require("aws-sdk");
AWS.config.update({
endpoint: 'http://dynamodb.us-east-1.amazonaws.com',
accessKeyId: 'AKIA25JOAQ7DRXMKY2FO',
secretAccessKey: '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',
region: 'us-east-1',
});
var docClient = new AWS.DynamoDB.DocumentClient();
//Prueba de Put
/*var table = "Usuarios";
var Nombre = "ha ha ha";
var Mail = "pedrohelbling1998@gmail.com";
var params = {
TableName:table,
Item:{
"Nombre": Nombre,
"Email": Mail
}
};
console.log("Adding a new item...");
docClient.put(params, function(err, data) {
if (err) {
console.error("Unable to add item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("Added item:", JSON.stringify(data, null, 2));
}
});*/
//Prueba de GET
var table2 = "Usuarios";
var Nombre = "Pedro";
var Mail = "pedrohelbling1998@gmail.com";
var params2 = {
TableName: table2,
Key:{
"Nombre": Nombre
}
};
docClient.get(params2, function(err, data) {
if (err) {
console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("GetItem succeeded:", JSON.stringify(data, null, 2));
}
});