Skip to content
Snippets Groups Projects
Usuarios.js 1.2 KiB
Newer Older
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));
    }
});