-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-table.js
61 lines (59 loc) · 1.33 KB
/
create-table.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var AWS = require('aws-sdk');
AWS.config.loadFromPath('./config.local.json');
var ddb = new AWS.DynamoDB({apiVersion: '2012-08-10'});
ddb.deleteTable({
TableName : "XmasList"
})
var params = {
AttributeDefinitions: [
{
AttributeName: 'pk',
AttributeType: 'S'
},
{
AttributeName: 'sk',
AttributeType: 'S'
}
],
KeySchema: [
{
AttributeName: 'pk',
KeyType: 'HASH'
},
{
AttributeName: 'sk',
KeyType: 'RANGE'
}
],
ProvisionedThroughput: {
ReadCapacityUnits: 5,
WriteCapacityUnits: 5
},
GlobalSecondaryIndexes: [
{
IndexName:'list_owner_index',
KeySchema: [
{
AttributeName: 'sk',
KeyType: 'HASH'
},
{
AttributeName: 'pk',
KeyType: 'RANGE'
}
],
Projection: {
ProjectionType: "ALL"
},
ProvisionedThroughput: {
ReadCapacityUnits: 5,
WriteCapacityUnits: 5
}
}
],
TableName: "XmasList"
};
ddb.createTable(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});