knex query , promises.
TL; DR: :
add_authentication_type()
.then(add_default_user)
.then(add_categories)
, , , :
// A
.then(add_default_user)
// B
.then(() => add_default_user())
// C
.then(add_default_user())
// D
.then(() => add_default_user)
then
, . A
add_default_user
, . B
, , . then
, , promises.
C
, , then
, . promises, , , undefined, , , , .
D
, , then
, add_default_user
!
, , ( " ", ).
foo()
.then((fooResult) => bar(fooResult)
.then((barResult)=> qux(barResult)
.then((quxResult)=> baz(quxResult)
)
)
)
, . , then
, , then
. , , , . , :
foo()
.then((fooResult) => bar(fooResult))
.then((barResult)=> qux(barResult))
.then((quxResult)=> baz(quxResult))
** PROTIP: ** , Promise.resolve()
:
Promise.resolve()
.then(() => knex('table1').del())
.then(() => knex('table2').del())
.then(() => knex('table3').del())