@@ -6,12 +6,15 @@ The context stored by this module consists of the following data elements:
66
77* ** installedAppId** : the UUID of the installed app instance. This is the primary key of the table.
88* ** locationId** : the UUID of the location in which the app is installed
9+ * ** locale** : the locale client used to install the app
910* ** authToken** : the access token used in calling the API
1011* ** refreshToken** : the refresh token used in generating a new access token when one expires
1112* ** config** : the current installed app instance configuration, i.e. selected devices, options, etc.
13+ * ** state** : name-value storage for the installed app instance
1214
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._ **
1518
1619## Installation
1720
@@ -34,14 +37,17 @@ The more extensive set of options are shown in this example:
3437smartapp .contextStore (new DynamoDBContextStore (
3538 {
3639 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
4246 },
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
4551 }
4652))
4753```
@@ -51,6 +57,7 @@ The **table** configuration options are:
5157* ** name** -- The name of the DynamoDB table storing the context
5258* ** hashKey** -- The name of the partition key of the table
5359* ** 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 `
5461* ** readCapacityUnits** -- Number of consistent reads per second. Used only when table is created
5562* ** writeCapacityUnits** -- Number of writes per second. Used only when table is created
5663* ** 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
6673
6774### AWS Configuration Options
6875
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 :
7178
7279``` javascript
7380smartapp .contextStore (new DynamoDBContextStore (
7481 {
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+ },
8888 region: ' us-east-2'
8989 }
9090 }
@@ -127,3 +127,19 @@ smartapp.contextStore(new DynamoDBContextStore(
127127 }
128128))
129129```
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