Promise.all not behaving as expected
In the case where
postId
is defined, i would expect the Promise.all
to wait for the post update. Instead, it only works if i do await db.update
. Shouldn't postId && db.update
resolve to just the db.update
value?
if this is a bug i can create a GH issue7 Replies
This is javascript
How can drizzle affect the behavior of promise.all?
im not so sure about this:
this code will log "done" after both sleep statements complete
Hmm, Drizzle implement lazy promises on all the query builders
try this:
I'm not sure I'd write code like this though
so for any promise.all, is it required to either do
await
or add .execute
at the end?Don't do await, use the execute, this will actually convert it to a normal promise
why is it better to not use await? and are there other use-cases for
.execute()
?because if you use await you defeat the purpose of promise.all
You will await it
You'll be basically passing an unwrapped promise, that has already been awaited
The
execute
method will turn the query builder into a regular promise.
Without it, the query builder behave like any other regular object, but if you await it, it becomes a promise that's now being resolved