import { getManager } from 'typeorm' ; import { Weapon } from '@Entities/Weapon' ; import { getResource } from './Shared' ; import { DecreaseAmmoOutDto } from '@Interfaces' ; export namespace WeaponRepository { export const Get = async ( weaponName ) : Promise < Weapon > => { return await getResource ( Weapon , { where : { name : weaponName } } ) ; } ; export const DecreaseAmmo = async ( weaponName ) : Promise < DecreaseAmmoOutDto > => { const weapon = await getResource ( Weapon , { where : { name : weaponName } } ) ; weapon . ammo = weapon . ammo - 1 ; getManager ( ) . save ( weapon ) ; return { remainingAmmo : weapon . ammo } ; } ; }