Created
January 11, 2021 16:49
-
-
Save qodirovshohijahon/5c3ef3857572cb26544cdf5484353de8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const myQuizList = async ( | |
req: IRequest, | |
res: Response, | |
next: NextFunction | |
) => { | |
try { | |
const quizRepo = await quizRepository() | |
const user: any = req.sessionData?.user | |
console.log('-----------', req.sessionData) | |
if (!user) { | |
return new ApiResponse(res).error(404, 'USER_NOT_FOUND') | |
} | |
const data: Quiz = await quizRepo.paginate({ | |
...req.query, | |
where: { | |
categoryId: req.query.categoryId, | |
deleted: false, | |
isPrivate: false, | |
author: user?.id, | |
}, | |
relations: ['user', 'author'], | |
columns: ['title', 'author'], | |
}) | |
if (!data) { | |
return new ApiResponse(res).error(404, 'QUIZES_NOT_FOUND') | |
} | |
new ApiResponse(res).success(data) | |
} catch (e) { | |
console.error(e) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment