-
Notifications
You must be signed in to change notification settings - Fork 4
/
CreateTable.js
70 lines (65 loc) · 1.82 KB
/
CreateTable.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
62
63
64
65
66
67
68
69
70
var AWS = require("aws-sdk");
/*Use this for AWS Console*/
//AWS.config.loadFromPath('../keys.json');
/*Use this for local setup*/
// AWS.config.update({
// region: "local",
// endpoint: "http://localhost:8000"
// });
var dynamodb = new AWS.DynamoDB();
var params = {
TableName : "V-Transfer",
KeySchema: [
{ AttributeName: "PK", KeyType: "HASH"}, //Partition key
{ AttributeName: "SK", KeyType: "RANGE" } //Sort key
],
AttributeDefinitions: [
{ AttributeName: "PK", AttributeType: "S" },
{ AttributeName: "SK", AttributeType: "S" },
{ AttributeName: "GS1_PK", AttributeType: "S" },
{ AttributeName: "LS1_SK", AttributeType: "S"}
],
ProvisionedThroughput: {
ReadCapacityUnits: 10,
WriteCapacityUnits: 10
},
GlobalSecondaryIndexes: [{
IndexName: "FIND_FILE_BY_URLID",
KeySchema: [
{
AttributeName: "GS1_PK",
KeyType: "HASH"
}
],
Projection: {
ProjectionType: "ALL"
},
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1
}
}],
LocalSecondaryIndexes: [{
IndexName: "FIND_FILE_BY_NAME",
KeySchema: [
{
AttributeName: "PK",
KeyType: "HASH"
},
{
AttributeName: "LS1_SK",
KeyType: "RANGE"
}
],
Projection: {
ProjectionType: "ALL"
}
}]
};
dynamodb.createTable(params, function(err, data) {
if (err) {
console.error("Unable to create table. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("Created table. Table description JSON:", JSON.stringify(data, null, 2));
}
});