I have three Sequelize models as follows:
User (userId, userName, moneyInWallet)
Product (productId, productName, price)
Purchase (purchaseId, buyingUser, quantity, dateOfPurchase)
I now wanted to write a 'post' method in typescript to insert a record into 'Purchase' model only if the 'moneyInWallet' of a user in 'User' model is greater than 'price' of the product from 'Product' model like:
purchaseController.post('/add/',
(req: Request, res: Response) => {
/* logic here*/
})
Can someone please help me with this...
Thanks in advance!!