import { AbstractRepository, EntityManager, EntityRepository, getManager, } from 'typeorm'; import { RawGoogleProductPage } from '@/entities'; import { RawGoogleShoppingProductDataV1 } from '@/entities/RawGoogleProductPage/types'; /** * Repository for the RawGoogleShoppingProduct entity. */ @EntityRepository(RawGoogleProductPage) // eslint-disable-next-line max-len export default class RawGoogleShoppingProductRepository extends AbstractRepository { /** * Creates a raw google shopping product in the db. */ async create( { googleShoppingId, data, }: { googleShoppingId: string; data: RawGoogleShoppingProductDataV1; }, manager: EntityManager = getManager() ): Promise { const rawGoogleShoppingProduct = await manager.save( RawGoogleProductPage, manager.create(RawGoogleProductPage, { googleShoppingId, rawData: data, }) ); return rawGoogleShoppingProduct; } }