How to save an array of products at checkout?

Viewed 22

I have two tables, the first is Products, and the second is Orders. To link Many to Many, I created a 3 table, and in the first two, I wrote the relationship

--Products--             --Orders--            --OrdersProducts--
Name                      Username               id
Price                     Phone                  orderId
Desc_text                 Email                  productId
Image                     

I'm not sure I chose the right relationship. I want to create an order, an array of product IDs added to the order! When testing in Postman, I add the necessary fields through the form, the order is formed, but when viewing through PGAdmin connection table is empty!

Here is the request to create an order

{
    "username": "test",
    "phone": "5 632 656 52 26",
    "email": "test@test.ru",
    "address": "test",
    "products": ["1","2"]

}

What am I doing wrong?

0 Answers
Related