Issues (10)

dynamodb_local_schema.js (3 issues)

1
var params = {
2
    TableName: 'test_model',
3
    KeySchema: [ // The type of of schema.  Must start with a HASH type, with an optional second RANGE.
4
        { // Required HASH type attribute
5
            AttributeName: 'id',
6
            KeyType: 'HASH',
7
        }
8
    ],
9
    AttributeDefinitions: [ // The names and types of all primary and index key attributes only
10
        {
11
            AttributeName: 'id',
12
            AttributeType: 'S', // (S | N | B) for string, number, binary
13
        },
14
        {
15
            AttributeName: 'count',
16
            AttributeType: 'N', // (S | N | B) for string, number, binary
17
        }
18
    ],
19
    ProvisionedThroughput: { // required provisioned throughput for the table
20
        ReadCapacityUnits: 1,
21
        WriteCapacityUnits: 1,
22
    },
23
    GlobalSecondaryIndexes: [ // optional (list of GlobalSecondaryIndex)
24
        {
25
            IndexName: 'count_index',
26
            KeySchema: [
27
                { // Required HASH type attribute
28
                    AttributeName: 'count',
29
                    KeyType: 'HASH',
30
                }
31
            ],
32
            Projection: { // attributes to project into the index
33
                ProjectionType: 'ALL', // (ALL | KEYS_ONLY | INCLUDE)
34
            },
35
            ProvisionedThroughput: { // throughput to provision to the index
36
                ReadCapacityUnits: 1,
37
                WriteCapacityUnits: 1,
38
            },
39
        },
40
        // ... more global secondary indexes ...
41
    ]
42
};
43
dynamodb.createTable(params, function(err, data) {
0 ignored issues
show
The variable dynamodb seems to be never declared. If this is a global, consider adding a /** global: dynamodb */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
44
    if (err) print(err); // an error occurred
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
45
    else print(data); // successful response
46
});
47
48
// Table with composite keys:
49
50
params = {
51
    TableName: 'composite_test_model',
52
    KeySchema: [ // The type of of schema.  Must start with a HASH type, with an optional second RANGE.
53
        { // Required HASH type attribute
54
            AttributeName: 'id',
55
            KeyType: 'HASH',
56
        },
57
        {
58
            AttributeName: 'id2',
59
            KeyType: 'RANGE',
60
        }
61
    ],
62
    AttributeDefinitions: [ // The names and types of all primary and index key attributes only
63
        {
64
            AttributeName: 'id',
65
            AttributeType: 'S', // (S | N | B) for string, number, binary
66
        },
67
        {
68
            AttributeName: 'id2',
69
            AttributeType: 'S', // (S | N | B) for string, number, binary
70
        },
71
        {
72
            AttributeName: 'count',
73
            AttributeType: 'N', // (S | N | B) for string, number, binary
74
        }
75
    ],
76
    ProvisionedThroughput: { // required provisioned throughput for the table
77
        ReadCapacityUnits: 1,
78
        WriteCapacityUnits: 1,
79
    },
80
    GlobalSecondaryIndexes: [ // optional (list of GlobalSecondaryIndex)
81
        {
82
            IndexName: 'count_index',
83
            KeySchema: [
84
                { // Required HASH type attribute
85
                    AttributeName: 'count',
86
                    KeyType: 'HASH',
87
                }
88
            ],
89
            Projection: { // attributes to project into the index
90
                ProjectionType: 'ALL', // (ALL | KEYS_ONLY | INCLUDE)
91
            },
92
            ProvisionedThroughput: { // throughput to provision to the index
93
                ReadCapacityUnits: 1,
94
                WriteCapacityUnits: 1,
95
            },
96
        },
97
        {
98
            IndexName: 'id_count_index',
99
            KeySchema: [
100
                { // Required HASH type attribute
101
                    AttributeName: 'id',
102
                    KeyType: 'HASH',
103
                },
104
                {
105
                    AttributeName: 'count',
106
                    KeyType: 'RANGE',
107
                }
108
            ],
109
            Projection: { // attributes to project into the index
110
                ProjectionType: 'ALL', // (ALL | KEYS_ONLY | INCLUDE)
111
            },
112
            ProvisionedThroughput: { // throughput to provision to the index
113
                ReadCapacityUnits: 1,
114
                WriteCapacityUnits: 1,
115
            },
116
        },
117
        // ... more global secondary indexes ...
118
    ]
119
};
120
dynamodb.createTable(params, function(err, data) {
121
    if (err) print(err); // an error occurred
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
122
    else print(data); // successful response
123
});
124