I m new to loopback so don't know how to solve this kind of situations suppose I have model sale and model stock here is my code
Sales.beforeRemote('create', function (ctx, user, next) {
var stock=app.models.estshopinventory
var value= stock.find({where: {product_id:1}})// is this possible to assign value which got from stock
});
if users sale tv which price is 1000 and quantity 1 then it searches in stock table & if it found (productname) tv in stock then it does some calculations suppose data in stock before calculation like
productname | quantity | price
tv | 1 | 1000
after calculation (stock table)
productname | quantity | price
tv | 1 | 1000
how I can do this thing in loopback because I haven't found anything on google related to this kind of problem note I don't want to use multiple api or is there any other method to achieve this