I have two models Purchase and Products, and productId is common for both.
I need to find the productDetails from product model for a purchaseId.
So I have created a custom endpoint in Purchase model, called getProductDetails.
This is how I am trying to query the models.
Purchase.find({
"filter": {
include: {
relation: 'Product',
scope: {
fields: ['productDesc'],
}
}
},
where:{
id:purchaseId
},
My relation is Purchase belongsTo Product, foreignKey being productId
Product hasMany Purchase
But even when I do the above query, I do not get productDesc in query result
Is my model relation wrong ?