UNPKG

1.13 kBJavaScriptView Raw
1const AWS = require('aws-sdk');
2const dynatable = require('./dist');
3
4AWS.config.update({
5 region: "eu-west-1",
6 accessKeyId: "AKIAJ3CHSVCEKPUVGPXA",
7 secretAccessKey: "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"
8});
9
10const docClient = new AWS.DynamoDB.DocumentClient();
11
12// var params = {
13// TableName : 'proj50',
14// // FilterExpression : 'Year = :this_year',
15// // ExpressionAttributeValues : {':this_year' : 2015}
16// };
17//
18// var documentClient = new AWS.DynamoDB.DocumentClient();
19//
20// documentClient.scan(params, function(err, data) {
21// if (err) console.log(err);
22// else console.log(data);
23// });
24
25// Imagine you have a DynamoDB table called `users`
26const users = dynatable(docClient, 'proj50', { id: 'N' });
27users.find()
28 .then(res => console.log(res))
29 .catch(err => console.log(err));
30
31// users.findOne({name: { $in: ['Nisse'] }})
32// .then(users => console.log(users));
33
34// users.update({id: 11}, { name: 'Nisse2' })
35// .then(res => console.log(res))
36// .catch(err => console.log(err));
37
38// users.put({
39// id: 11,
40// name: 'Nisse',
41// added: new Date(),
42// interests: ['cars', 'farts']
43// });