@@ -6,12 +6,15 @@ The context stored by this module consists of the following data elements:
6
6
7
7
* ** installedAppId** : the UUID of the installed app instance. This is the primary key of the table.
8
8
* ** locationId** : the UUID of the location in which the app is installed
9
+ * ** locale** : the locale client used to install the app
9
10
* ** authToken** : the access token used in calling the API
10
11
* ** refreshToken** : the refresh token used in generating a new access token when one expires
11
12
* ** config** : the current installed app instance configuration, i.e. selected devices, options, etc.
13
+ * ** state** : name-value storage for the installed app instance
12
14
13
- _ Note: Version 2.X.X is a breaking change to version 1.X.X as far as configuring the context store is
14
- concerned, but either one can be used with any version of the SmartThings SDK._
15
+ ** _ Note: Version 3.X.X is a breaking change to version 2.X.X as far as configuring the context store is
16
+ concerned, but either one can be used with any version of the SmartThings SDK. The new state storage
17
+ functions are only available with version 5.X.X or later of the SDK._ **
15
18
16
19
## Installation
17
20
@@ -34,14 +37,17 @@ The more extensive set of options are shown in this example:
34
37
smartapp .contextStore (new DynamoDBContextStore (
35
38
{
36
39
table: {
37
- name: ' custom-table' , // defaults to 'smartapp'
38
- hashKey: ' key1' , // defaults to 'id'
39
- prefix: ' context' , // defaults to 'ctx'
40
- readCapacityUnits: 10 , // defaults to 5, applies to automatic creation only
41
- writeCapacityUnits: 10 // defaults to 5, applies to automatic creation only
40
+ name: ' custom-table' , // defaults to 'smartapp'
41
+ hashKey: ' key1' , // defaults to 'id'
42
+ prefix: ' context' , // defaults to 'ctx'
43
+ billingMode: ' PROVISIONED' , // defaults to 'PAY_PER_REQUEST'
44
+ readCapacityUnits: 10 , // defaults to 1, applies to automatic creation only
45
+ writeCapacityUnits: 10 // defaults to 1, applies to automatic creation only
42
46
},
43
- AWSRegion: ' us-east-2' , // defaults to 'us-east-1'
44
- autoCreate: true // defaults to true
47
+ aws: {
48
+ region: ' us-east-2' , // defaults to 'us-east-1'
49
+ },
50
+ autoCreate: true // defaults to true
45
51
}
46
52
))
47
53
```
@@ -51,6 +57,7 @@ The **table** configuration options are:
51
57
* ** name** -- The name of the DynamoDB table storing the context
52
58
* ** hashKey** -- The name of the partition key of the table
53
59
* ** prefix** -- A string pre-pended to the installed app ID and used as the partition key for the entry
60
+ * ** billingMode** -- The billing mode of the table. Either ` PAY_PER_REQUEST ` or ` PROVISIONED `
54
61
* ** readCapacityUnits** -- Number of consistent reads per second. Used only when table is created
55
62
* ** writeCapacityUnits** -- Number of writes per second. Used only when table is created
56
63
* ** sortKey** -- Optional sort key definition (see below for more details)
@@ -66,25 +73,18 @@ Note that only one of the AWS options should be specified or behavior will be in
66
73
67
74
### AWS Configuration Options
68
75
69
- By default, the AWS credentials are picked up from the environment. If you prefer you can read the credentials
70
- from a file with this configuration :
76
+ By default, the AWS credentials are picked up from the environment. If you prefer you can
77
+ explicitly set the credentials in this way :
71
78
72
79
``` javascript
73
80
smartapp .contextStore (new DynamoDBContextStore (
74
81
{
75
- AWSConfigPath: ' ./path/to/file.json'
76
- }
77
- ))
78
- ```
79
-
80
- You can also explicitly set the credentials in this way:
81
-
82
- ``` javascript
83
- smartapp .contextStore (new DynamoDBContextStore (
84
- {
85
- AWSConfigJSON: {
86
- accessKeyId: ' <YOUR_ACCESS_KEY_ID>' ,
87
- secretAccessKey: ' <YOUR_SECRET_ACCESS_KEY>' ,
82
+ aws: {
83
+ endpoint: ' http://localhost:8000' ,
84
+ credentials: {
85
+ accessKeyId: ' <YOUR_ACCESS_KEY_ID>' ,
86
+ secretAccessKey: ' <YOUR_SECRET_ACCESS_KEY>' ,
87
+ },
88
88
region: ' us-east-2'
89
89
}
90
90
}
@@ -127,3 +127,19 @@ smartapp.contextStore(new DynamoDBContextStore(
127
127
}
128
128
))
129
129
```
130
+
131
+ ### Partition Key Prefix
132
+
133
+ The default behavior is to construction the partition key of the context records from the installedAppId with
134
+ the prefix ` pre: ` . If you want to override this prefix you can do so by specifying the ` prefix ` option:
135
+
136
+ ``` javascript
137
+ smartapp .contextStore (new DynamoDBContextStore (
138
+ {
139
+ table: {
140
+ name: ' my-application' ,
141
+ prefix: ' context$'
142
+ }
143
+ }
144
+ ))
145
+ ```
0 commit comments