Reputation: 35
Here is the customerservices retrieving all the carts item and the result look like this
{
"status": 200,
"msg": "success",
"result": [
{
"cart_id": 7,
"customer_id": 1,
"product_id": 12,
"quantity": 1,
"price": 150,
"createdAt": "2025-02-28",
"updatedAt": "2025-02-28"
}
]
Now I have a foreign key in product_id referencing the products table "id", below I have the code to retrieve the carts data
const cartdata = await this.cartModel.findAll(
{include: [
{
model: , // The model for the products table
as: 'product', // Alias for the join, if needed (optional)
attributes: ['product_name', 'price'], // Specify which fields to include from the products table
},
],}
);
In the model property, I need to pass the ProductModel, but the productModel is not in customerservices, it is in dataservices. What can I do to solve this problem?
Upvotes: 0
Views: 26