Something went wrong. Try again.
A social knowledge tool for researchers built on ATProto
Something went wrong. Try again.
2.4 kB · 68 lines
TypeScript
at development
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869import { 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<PaginatedQueryResult<UrlCardQueryResultDTO>> { return this.urlCardQueryService.getUrlCardsOfUser(userId, options); }
async getCardsInCollection( collectionId: string, options: CardQueryOptions, ): Promise<PaginatedQueryResult<CollectionCardQueryResultDTO>> { return this.collectionCardQueryService.getCardsInCollection( collectionId, options, ); }
async getUrlCardView(cardId: string): Promise<UrlCardViewDTO | null> { return this.urlCardQueryService.getUrlCardView(cardId); }
async getLibrariesForCard(cardId: string): Promise<string[]> { return this.libraryQueryService.getLibrariesForCard(cardId); }
async getLibrariesForUrl( url: string, options: CardQueryOptions, ): Promise<PaginatedQueryResult<LibraryForUrlDTO>> { return this.urlCardQueryService.getLibrariesForUrl(url, options); }
async getNoteCardsForUrl( url: string, options: CardQueryOptions, ): Promise<PaginatedQueryResult<NoteCardForUrlDTO>> { return this.noteCardQueryService.getNoteCardsForUrl(url, options); }}