|
| 1 | +## loopback-connector-dynamodb |
| 2 | + |
| 3 | +DynamoDB connector for loopback-datasource-juggler. Because Dynamo doesn't get enough love. |
| 4 | + |
| 5 | +## DynamoDB connector |
| 6 | + |
| 7 | + * Installation |
| 8 | + * Creating a DynamoDB data source |
| 9 | + * Properties |
| 10 | + * Using the DynamoDB connector |
| 11 | + * Local development with DynamoDB Local |
| 12 | + |
| 13 | +### Installation |
| 14 | + |
| 15 | +In your application root directory, enter: |
| 16 | + |
| 17 | + $ npm install loopback-connector-dynamodb --save |
| 18 | + |
| 19 | +This will install the module from npm and add it as a depenency to the application's [package.json](http://docs.strongloop.com/display/LB/package.json) file. |
| 20 | + |
| 21 | +### Creating a DynamoDB data source |
| 22 | + |
| 23 | +Use the [Datasource generator](http://docs.strongloop.com/display/LB/Datasource+generator) to add a DynamoDB data source to your application. The entry in the application's `/server/datasources.json` will look like this: |
| 24 | + |
| 25 | +```json |
| 26 | +"mydb": { |
| 27 | + "name": "mydb", |
| 28 | + "connector": "dynamodb" |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +Edit `datasources.json` to add other properties to enable you to connect the data source to a DynamoDB database. |
| 33 | + |
| 34 | +### Properties |
| 35 | + |
| 36 | +Property | Type | Description |
| 37 | +-------- | ---- | ----------- |
| 38 | +connector | String | Connector name, either `loopback-connector-dynamodb` or `dynamodb` |
| 39 | +region | String | AWS Region to connect to. May also be set to `local` to use an instance of DynamoDB Local. |
| 40 | +debug | Boolean | If `true`, turn on verbose mode to debug requests and lifecycle. |
| 41 | +credentials | String | Method to locate credentials for the AWS SDK for Javascript. Valid values are: `env`, `shared`, `iamrole`, `file`. Default value: `shared`. |
| 42 | +credfile | String | If credentials method is `file`, specify the location of the JSON file to load. |
| 43 | +profile | String | Name the profile to use if using the `shared` credentials method. |
| 44 | +endpoint | Number | URL to use connecting to DynamoDB Local. Default is `8000`. Example: `http://localhost:8000/` Note: this property is ignored if `region` is not `local`. |
| 45 | + |
| 46 | +For example: |
| 47 | + |
| 48 | +*Example datasources.json file* |
| 49 | +```json |
| 50 | +{ |
| 51 | + "dynamo_dev": { |
| 52 | + "name": "dynamo_dev", |
| 53 | + "connector": "dynamodb", |
| 54 | + "region": "local", |
| 55 | + "credentials": "shared", |
| 56 | + "profile": "localdev", |
| 57 | + "port": 4567 |
| 58 | + }, |
| 59 | + "dynamo_qa": { |
| 60 | + "name": "dynamo_qa", |
| 61 | + "connector": "dynamodb", |
| 62 | + "region": "us-west-2", |
| 63 | + "credentials": "iamrole" |
| 64 | + } |
| 65 | +} |
| 66 | +``` |
| 67 | + |
| 68 | +:warning: You can't specify `aws_access_key_id` and `aws_secret_access_key` directly in your `datasources.json` file. |
| 69 | +This is intentional. Putting credentials like that into a file are A Very Bad Thing. Quit trying to do that. |
0 commit comments