import { getManager } from 'typeorm' ; import { Planet } from '@Entities/Planet' ; import { getResource } from './Shared' ; import { DecreaseShieldOutDto } from '@Interfaces' ; export namespace PlanetRepository { export const Get = async ( planetName ) : Promise < Planet > => { return await getResource ( Planet , { where : { name : planetName } } ) ; } ; export const DecreaseShield = async ( planetName , remainingShield ) : Promise < DecreaseShieldOutDto > => { const planet = await getResource ( Planet , { where : { name : planetName } } ) ; planet . shield = remainingShield ; await getManager ( ) . save ( planet ) ; return { remainingShield : planet . shield } ; } ; }