File tree Expand file tree Collapse file tree 1 file changed +2
-16
lines changed
Expand file tree Collapse file tree 1 file changed +2
-16
lines changed Original file line number Diff line number Diff line change 33const db = require ( '../server/db' )
44const { User} = require ( '../server/db/models' )
55
6- /**
7- * Welcome to the seed file! This seed file uses a newer language feature called...
8- *
9- * -=-= ASYNC...AWAIT -=-=
10- *
11- * Async-await is a joy to use! Read more about it in the MDN docs:
12- *
13- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
14- *
15- * Now that you've got the main idea, check it out in practice below!
16- */
17-
186async function seed ( ) {
197 await db . sync ( { force : true } )
208 console . log ( 'db synced!' )
21- // Whoa! Because we `await` the promise that db.sync returns, the next line will not be
22- // executed until that promise resolves!
9+
2310 const users = await Promise . all ( [
2411 User . create ( { email :
'[email protected] ' , password :
'123' } ) , 2512 User . create ( { email :
'[email protected] ' , password :
'123' } ) 2613 ] )
27- // Wowzers! We can even `await` on the right-hand side of the assignment operator
28- // and store the result that the promise resolves to in a variable! This is nice!
14+
2915 console . log ( `seeded ${ users . length } users` )
3016 console . log ( `seeded successfully` )
3117}
You can’t perform that action at this time.
0 commit comments