import { EntityRepository , Repository } from 'typeorm' ; import ShippingEntity from '@/entity/shipping' ; @ EntityRepository ( ShippingEntity ) class ShippingRepository extends Repository < ShippingEntity > { async findByUserIdx ( userIdx ) { const shippings = await this . find ( { where : { user : userIdx , } , order : { createdAt : 'DESC' , } , } ) ; return shippings ; } async saveItem ( item ) { const savedShipping = await this . save ( item ) ; return { savedShipping } ; } async findByIdx ( idx ) { const shipping = await this . findOne ( { where : { idx } , relations : [ 'user' ] , } ) ; return shipping ; } async deleteItem ( item ) { await this . remove ( item ) ; } async findSelectedByUser ( userIdx ) { const shipping = await this . findOne ( { where : { user : userIdx , defaultShipping : true } , } ) ; return shipping ; } } export default ShippingRepository ;