Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 10x 10x 10x 10x 20x 2x 2x 1x 1x 1x 1x 1x 1x 3x | import { InjectRepository } from '@nestjs/typeorm'; import { ApiBookmarkGetRequestQueryDto } from 'src/bookmark/dto/api-bookmark-get-request-query.dto'; import { BookmarkEntity } from 'src/entities/bookmark.entity'; import { UserDto } from 'src/user/dto/user.dto'; import { In, IsNull, LessThan, Repository } from 'typeorm'; export class BookmarkQueryRepository { constructor( @InjectRepository(BookmarkEntity) private repository: Repository<BookmarkEntity>, ) {} async find(dto: ApiBookmarkGetRequestQueryDto, user: UserDto): Promise<BookmarkEntity[]> { const whereConditions = { user_uuid: user.uuid, archived_at: IsNull(), ...(dto.last_id > 0 ? { id: LessThan(dto.last_id) } : {}), }; return this.repository.find({ where: whereConditions, relations: { course: true }, order: { updated_at: 'DESC' }, take: dto.size, }); } async findOne(uuid: string): Promise<BookmarkEntity> { return this.repository.findOne({ where: { uuid, archived_at: IsNull() }, }); } async findList(uuids: string[]): Promise<BookmarkEntity[]> { return this.repository.find({ where: { uuid: In(uuids) }, }); } async findMyCourse(uuid: string): Promise<BookmarkEntity[]> { return this.repository.find({ where: { course_uuid: uuid, archived_at: IsNull() }, }); } async bookmarkSave(bookmarkEntity: BookmarkEntity) { return this.repository.save(bookmarkEntity); } async bookmarkDelete(bookmarkEntity: BookmarkEntity) { return this.repository.update({ id: bookmarkEntity.id }, { archived_at: new Date() }); } async bookmarkUpdate(bookmarkEntity: BookmarkEntity) { return this.repository.update({ id: bookmarkEntity.id }, { archived_at: null }); } async findUserBookmark(user: UserDto, uuid: string): Promise<BookmarkEntity> { return this.repository.findOne({ where: { user_uuid: user.uuid, course_uuid: uuid, archived_at: IsNull() }, }); } } |