Created
March 3, 2021 10:31
-
-
Save franko4don/b4b6fc1655dfd8bb6e91401551287c0f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /** | |
| * @api {get} /v2/chatstory Get Users' ChatStory | |
| * @apiName Get ChatStory | |
| * @apiGroup ChatStory | |
| */ | |
| async getChatStory(req, res) { | |
| const { userId } = req.body; | |
| try { | |
| const pageOptions = super.getPaginationOptions(req); | |
| let totalChatStory = await ChatStory.countDocuments({isActive: true, publishedStatus: 'published'}); | |
| let chatStory = await ChatStory.find({isActive: true, publishedStatus: 'published' }).skip(pageOptions.skipper) | |
| .limit(pageOptions.limit) | |
| .sort({ createdAt : -1}) | |
| .populate('genre') | |
| .populate('chatStoryLikes') | |
| .exec() | |
| chatStory.user = userId; | |
| let meta = super.getMeta(pageOptions, totalChatStory); | |
| return super.successPaginated(res, chatStory, meta, 'Chat Story'); | |
| } catch (error) { | |
| return super.actionFailure(res, `Couldn't get chatStorys`); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment