File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -8,12 +8,11 @@ export class CreatePets implements Seed {
88
99 public async seed ( factory : Factory , connection : Connection ) : Promise < any > {
1010 const em = connection . createEntityManager ( ) ;
11-
1211 await times ( 10 , async ( n ) => {
1312 const pet = await factory ( Pet ) ( ) . seed ( ) ;
1413 const user = await factory ( User ) ( ) . make ( ) ;
1514 user . pets = [ pet ] ;
16- await em . save ( user ) ;
15+ return await em . save ( user ) ;
1716 } ) ;
1817 }
1918
Original file line number Diff line number Diff line change @@ -11,5 +11,11 @@ export const isPromiseLike = (o: any): boolean => !!o && (typeof o === 'object'
1111/**
1212 * Times repeats a function n times
1313 */
14- export const times = async < TResult > ( n : number , iteratee : ( index : number ) => Promise < TResult > ) : Promise < TResult [ ] > =>
15- Promise . all ( new Array ( n ) . map ( async ( v , i ) => await iteratee ( i ) ) ) ;
14+ export const times = async < TResult > ( n : number , iteratee : ( index : number ) => Promise < TResult > ) : Promise < TResult [ ] > => {
15+ const rs = [ ] as TResult [ ] ;
16+ for ( let i = 0 ; i < n ; i ++ ) {
17+ const r = await iteratee ( i ) ;
18+ rs . push ( r ) ;
19+ }
20+ return rs ;
21+ } ;
You can’t perform that action at this time.
0 commit comments