forked from PalisadoesFoundation/talawa-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
list tags assigned to a user on it's profile
- Loading branch information
Showing
4 changed files
with
36 additions
and
14 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import type { UserResolvers } from "../../types/generatedGraphQLTypes"; | ||
// import { tagsAssignedWith } from "./tagsAssignedWith"; | ||
import { posts } from "./posts"; | ||
import { tagsAssigned } from "./tagsAssigned"; | ||
|
||
export const User: UserResolvers = { | ||
// tagsAssignedWith, | ||
posts, | ||
tagsAssigned, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ActionItemCategory, OrganizationTagUser, TagUser } from "../../models"; | ||
import type { | ||
OrganizationResolvers, | ||
UserResolvers, | ||
} from "../../types/generatedGraphQLTypes"; | ||
|
||
/** | ||
* Resolver function for the `actionItemCategories` field of an `Organization`. | ||
* | ||
* This function retrieves the action item categories related to a specific organization. | ||
* | ||
* @param parent - The parent object representing the organization. It contains information about the organization, including the ID of the organization. | ||
* @returns A promise that resolves to the action item category documents found in the database. These documents represent the action item categories related to the organization. | ||
* | ||
* @see ActionItemCategory - The ActionItemCategory model used to interact with the action item categories collection in the database. | ||
* @see OrganizationResolvers - The type definition for the resolvers of the Organization fields. | ||
* | ||
*/ | ||
export const tagsAssigned: UserResolvers["tagsAssigned"] = async (parent) => { | ||
const tags = await TagUser.find({ | ||
userId: parent._id, | ||
}).lean(); | ||
|
||
const tagIds = tags.map((tag) => tag.tagId); | ||
|
||
return await OrganizationTagUser.find({ | ||
_id: { $in: tagIds }, | ||
}) | ||
.sort({ _id: -1 }) | ||
.lean(); | ||
}; |
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
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