Skip to content

Commit e37fd91

Browse files
authored
Merge pull request #92 from nenti/v1
Added automatic seeding of all available seeds.
2 parents efd5724 + bceaf1e commit e37fd91

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ dynamodb:
127127
> sls dynamodb start --seed=domain,test
128128
```
129129

130+
If seed config is set to true, your configuration will be seeded automatically on startup. You can also put the seed to false to prevent initial seeding to use manual seeding via cli.
131+
132+
```fake-test-users.json example
133+
[
134+
{
135+
"id": "John",
136+
"name": "Doe",
137+
},
138+
]
139+
```
140+
130141
## Using DynamoDB Local in your code
131142
You need to add the following parameters to the AWS NODE SDK dynamodb constructor
132143

index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ class ServerlessDynamodbLocal {
148148
const options = _.merge({
149149
sharedDb: this.options.sharedDb || true
150150
},
151-
this.options,
152-
config && config.start
151+
config && config.start,
152+
this.options
153153
);
154154

155155
dynamodbLocal.start(options);
@@ -182,11 +182,15 @@ class ServerlessDynamodbLocal {
182182
const config = this.service.custom.dynamodb;
183183
const seedConfig = _.get(config, "seed", {});
184184
const seed = this.options.seed;
185-
if (!seed) {
186-
this.serverlessLog("DynamoDB - No seed categories defined. Skipping data seeding.");
185+
let categories;
186+
if (typeof seed === "string") {
187+
categories = seed.split(",");
188+
} else if(seed) {
189+
categories = Object.keys(seedConfig);
190+
} else { // if (!seed)
191+
this.serverlessLog("DynamoDB - No seeding defined. Skipping data seeding.");
187192
return [];
188193
}
189-
const categories = seed.split(",");
190194
const sourcesByCategory = categories.map((category) => seedConfig[category].sources);
191195
return [].concat.apply([], sourcesByCategory);
192196
}

0 commit comments

Comments
 (0)