Skip to content
Advertisement

Can someone clarify what is happening in this part of the code?

So I have part of code like this

I have database where I have table-categories and table-items categories table and items look like this:

enter image description here

enter image description here

What I don’t understand is what happens with categories and inventory in this part of code ->

Do they get joined? Also in this part

what item means here, there is no column named item in items table?

thank you!

Advertisement

Answer

This

  • makes two queries – one from categories, one from inventory
  • in parallel, with Promise.all
  • then takes the rows property from each query result and puts those into the categories and items variables.

They don’t get joined – they’re two entirely independent queries and get put into separate categories and items variables.

what item means here

With

items is the result of the query SELECT * FROM inventoryitem is a single row from that query.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement