@@ -155,23 +155,16 @@ class ServerlessDynamodbLocal {
155
155
const options = this . options ;
156
156
const dynamodb = this . dynamodbOptions ( options ) ;
157
157
158
- const seedPromise = BbPromise . each ( this . seedSources , ( source ) => {
158
+ return BbPromise . each ( this . seedSources , ( source ) => {
159
159
if ( ! source . table ) {
160
160
throw new Error ( "seeding source \"table\" property not defined" ) ;
161
161
}
162
- return seeder . locateSeeds ( source . sources || [ ] )
162
+ const seedPromise = seeder . locateSeeds ( source . sources || [ ] )
163
163
. then ( ( seeds ) => seeder . writeSeeds ( dynamodb . doc . batchWrite . bind ( dynamodb . doc ) , source . table , seeds ) ) ;
164
- } ) ;
165
-
166
- const rawSeedPromise = BbPromise . each ( this . rawSeedSources , ( source ) => {
167
- if ( ! source . table ) {
168
- throw new Error ( "Raw seeding source \"table\" property not defined" ) ;
169
- }
170
- return seeder . locateSeeds ( source . rawsources || [ ] )
164
+ const rawSeedPromise = seeder . locateSeeds ( source . rawsources || [ ] )
171
165
. then ( ( seeds ) => seeder . writeSeeds ( dynamodb . raw . batchWriteItem . bind ( dynamodb . raw ) , source . table , seeds ) ) ;
166
+ return BbPromise . all ( [ seedPromise , rawSeedPromise ] ) ;
172
167
} ) ;
173
-
174
- return BbPromise . all ( [ seedPromise , rawSeedPromise ] ) ;
175
168
}
176
169
177
170
removeHandler ( ) {
@@ -268,26 +261,6 @@ class ServerlessDynamodbLocal {
268
261
return [ ] . concat . apply ( [ ] , sourcesByCategory ) ;
269
262
}
270
263
271
- /**
272
- * Gets the raw seeding sources
273
- */
274
- get rawSeedSources ( ) {
275
- const config = this . service . custom . dynamodb ;
276
- const seedConfig = _ . get ( config , "seed" , { } ) ;
277
- const seed = this . options . seed || config . start . seed || seedConfig ;
278
- let categories ;
279
- if ( typeof seed === "string" ) {
280
- categories = seed . split ( "," ) ;
281
- } else if ( seed ) {
282
- categories = Object . keys ( seedConfig ) ;
283
- } else { // if (!seed)
284
- this . serverlessLog ( "DynamoDB - No seeding defined. Skipping data seeding." ) ;
285
- return [ ] ;
286
- }
287
- const sourcesByCategory = categories . map ( ( category ) => seedConfig [ category ] . rawsources ) ;
288
- return [ ] . concat . apply ( [ ] , sourcesByCategory ) ;
289
- }
290
-
291
264
createTable ( dynamodb , migration ) {
292
265
return new BbPromise ( ( resolve , reject ) => {
293
266
if ( migration . StreamSpecification && migration . StreamSpecification . StreamViewType ) {
0 commit comments