import { PostgresJsDatabase } from 'drizzle-orm/postgres-js'; import { ICardQueryRepository, CardQueryOptions, PaginatedQueryResult, UrlCardQueryResultDTO, CollectionCardQueryResultDTO, UrlCardViewDTO, LibraryForUrlDTO, NoteCardForUrlDTO, } from '../../domain/ICardQueryRepository'; import { UrlCardQueryService } from './query-services/UrlCardQueryService'; import { CollectionCardQueryService } from './query-services/CollectionCardQueryService'; import { LibraryQueryService } from './query-services/LibraryQueryService'; import { NoteCardQueryService } from './query-services/NoteCardQueryService'; export class DrizzleCardQueryRepository implements ICardQueryRepository { private urlCardQueryService: UrlCardQueryService; private collectionCardQueryService: CollectionCardQueryService; private libraryQueryService: LibraryQueryService; private noteCardQueryService: NoteCardQueryService; constructor(private db: PostgresJsDatabase) { this.urlCardQueryService = new UrlCardQueryService(db); this.collectionCardQueryService = new CollectionCardQueryService(db); this.libraryQueryService = new LibraryQueryService(db); this.noteCardQueryService = new NoteCardQueryService(db); } async getUrlCardsOfUser( userId: string, options: CardQueryOptions, ): Promise> { return this.urlCardQueryService.getUrlCardsOfUser(userId, options); } async getCardsInCollection( collectionId: string, options: CardQueryOptions, ): Promise> { return this.collectionCardQueryService.getCardsInCollection( collectionId, options, ); } async getUrlCardView(cardId: string): Promise { return this.urlCardQueryService.getUrlCardView(cardId); } async getLibrariesForCard(cardId: string): Promise { return this.libraryQueryService.getLibrariesForCard(cardId); } async getLibrariesForUrl( url: string, options: CardQueryOptions, ): Promise> { return this.urlCardQueryService.getLibrariesForUrl(url, options); } async getNoteCardsForUrl( url: string, options: CardQueryOptions, ): Promise> { return this.noteCardQueryService.getNoteCardsForUrl(url, options); } }