I am currently building an e-commerce site. I am using Express, with Mongodb. I currently have three models.
- Users { a user can be an owner or a buyer, I've set up a couple of flags like isOwner, etc}
- Products { name, description, and an object of user ref: 'Users' }
- Orders { orderItems[which is an array of Products, has an object ID of Products (ref: 'Products')], paymentMethod, and an object of a user ref: 'Users' }
My question is: If a customer comes and add multiple Products to cart the products belong to different Users('Owners') which I am saving in as an array in as "orderItems". How will I make a GET request for the Owner of that specific Item that he just got an order? And is this the correct way of doing it? or should I make another document for OrderItems?