mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-18 05:09:29 +00:00
add decks documentation
This commit is contained in:
@@ -4,6 +4,7 @@ import { createPrismaOrderBy } from '../../../infrastructure/common/helpers/get-
|
||||
import { Pagination } from '../../../infrastructure/common/pagination/pagination.service'
|
||||
import { PrismaService } from '../../../prisma.service'
|
||||
import { GetAllDecksDto } from '../dto'
|
||||
import { Deck, PaginatedDecks } from '../entities/deck.entity'
|
||||
|
||||
@Injectable()
|
||||
export class DecksRepository {
|
||||
@@ -21,7 +22,7 @@ export class DecksRepository {
|
||||
userId: string
|
||||
cover?: string
|
||||
isPrivate?: boolean
|
||||
}) {
|
||||
}): Promise<Deck> {
|
||||
try {
|
||||
return await this.prisma.deck.create({
|
||||
data: {
|
||||
@@ -35,6 +36,14 @@ export class DecksRepository {
|
||||
cover,
|
||||
isPrivate,
|
||||
},
|
||||
include: {
|
||||
author: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
} catch (e) {
|
||||
this.logger.error(e?.message)
|
||||
@@ -51,9 +60,7 @@ export class DecksRepository {
|
||||
minCardsCount,
|
||||
maxCardsCount,
|
||||
orderBy,
|
||||
}: GetAllDecksDto) {
|
||||
console.log(minCardsCount)
|
||||
console.log(Number(minCardsCount))
|
||||
}: GetAllDecksDto): Promise<PaginatedDecks> {
|
||||
try {
|
||||
const where = {
|
||||
cardsCount: {
|
||||
@@ -163,13 +170,21 @@ export class DecksRepository {
|
||||
public async updateDeckById(
|
||||
id: string,
|
||||
data: { name?: string; cover?: string; isPrivate?: boolean }
|
||||
) {
|
||||
): Promise<Deck> {
|
||||
try {
|
||||
return await this.prisma.deck.update({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
data,
|
||||
include: {
|
||||
author: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
} catch (e) {
|
||||
this.logger.error(e?.message)
|
||||
|
||||
Reference in New Issue
Block a user