Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

typeorm decrement

 /**Follow the example below**/
import { Product } from './../entities/product.entity';
import { EntityRepository, Repository, getManager } from 'typeorm';
import { Sales } from './../entities/sales.entity';
import { CreateSaleDto } from './../sales/dto/create-sale.dto';

@EntityRepository(Sales)
export class SalesRepository extends Repository<Sales> {
  
  private dataSource = getManager(); // EntityManager
    /**
   * This function will reduce the inventory of a product by a given quantity.
   * @param {number} id - number - the id of the product
   * @param {any} qty - number
   */
  private async reduceInventoryProduct(id: number, qty: any) {
    //inventory_min: It is the existing inventory of products and we are going to decrease as products are sold.
    // inventory_min: It is the field found in the products table in the database
    await this.dataSource.decrement(Product, { id: id }, 'inventory_min', qty);
  }
  	
}	

Comment

PREVIOUS NEXT
Code Example
Typescript :: java 8 collect multiple lists into single list 
Typescript :: typescrpt add onject to window namespace 
Typescript :: angular no internet detection 
Typescript :: outside click hook react 
Typescript :: ts new example 
Typescript :: Error in plugin @nomiclabs/hardhat-etherscan: The constructor for contracts/DAVID.sol:GuiltyDavid has 4 parameters but 0 arguments were provided instead. 
Typescript :: replace floats in dataframe 
Typescript :: typescript type specific strings 
Typescript :: set constraints for UIView swift 
Typescript :: readonly in typescript 
Typescript :: ubuntu display stdouts of processn 
Typescript :: conventional commits cheat sheet 
Typescript :: jest not tocontain 
Typescript :: typescript syntax 
Typescript :: styled components type argument generic 
Typescript :: Push Type Typescript 
Typescript :: angular material chips autocomplete example 
Typescript :: nuxtServerInit nuxt 3 
Typescript :: unknown type in typescript 
Typescript :: gatsby typescript starter hello world 
Typescript :: how to take union of two lists in python 
Typescript :: react hide elements from window print 
Typescript :: how to git pull all projects in a folder 
Typescript :: how t make fireball roblox or lua 
Typescript :: How to join all url segments to make a url in javascipt 30seconds of code 
Typescript :: no audio endpoints registered 
Typescript :: dto typescript 
Typescript :: how did mississauga get its name 
Typescript :: hack roblox account easy 
Typescript :: facade design pattern typescript 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =