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.
Merge branch 'checkin-checkoout' of https://github.com/git-init-priya…
…nshu/talawa-api-clone into checkin-checkoout
- Loading branch information
Showing
36 changed files
with
1,567 additions
and
68 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
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
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
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,68 @@ | ||
import type { PopulatedDoc, Document, Model, Types } from "mongoose"; | ||
import { Schema, model, models } from "mongoose"; | ||
import type { InterfaceUser } from "./User"; | ||
import type { InterfaceEvent } from "./Event"; | ||
import { createLoggingMiddleware } from "../libraries/dbLogger"; | ||
import type { InterfaceEventVolunteer } from "./EventVolunteer"; | ||
|
||
export interface InterfaceEventVolunteerGroup { | ||
_id: Types.ObjectId; | ||
createdAt: Date; | ||
creatorId: PopulatedDoc<InterfaceUser & Document>; | ||
eventId: PopulatedDoc<InterfaceEvent & Document>; | ||
leaderId: PopulatedDoc<InterfaceUser & Document>; | ||
name: string; | ||
updatedAt: Date; | ||
volunteers: PopulatedDoc<InterfaceEventVolunteer & Document>[]; | ||
volunteersRequired?: number; | ||
} | ||
|
||
const eventVolunteerGroupSchema = new Schema( | ||
{ | ||
creatorId: { | ||
type: Schema.Types.ObjectId, | ||
ref: "User", | ||
required: true, | ||
}, | ||
eventId: { | ||
type: Schema.Types.ObjectId, | ||
ref: "Event", | ||
required: true, | ||
}, | ||
leaderId: { | ||
type: Schema.Types.ObjectId, | ||
ref: "User", | ||
required: true, | ||
}, | ||
name: { | ||
type: String, | ||
required: true, | ||
}, | ||
volunteers: [ | ||
{ | ||
type: Schema.Types.ObjectId, | ||
ref: "EventVolunteer", | ||
default: [], | ||
}, | ||
], | ||
volunteersRequired: { | ||
type: Number, | ||
}, | ||
}, | ||
{ | ||
timestamps: true, | ||
}, | ||
); | ||
|
||
// Enable logging on changes in EventVolunteer collection | ||
createLoggingMiddleware(eventVolunteerGroupSchema, "EventVolunteerGroup"); | ||
|
||
const eventVolunteerGroupModel = (): Model<InterfaceEventVolunteerGroup> => | ||
model<InterfaceEventVolunteerGroup>( | ||
"EventVolunteerGroup", | ||
eventVolunteerGroupSchema, | ||
); | ||
|
||
// This syntax is needed to prevent Mongoose OverwriteModelError while running tests. | ||
export const EventVolunteerGroup = (models.EventVolunteerGroup || | ||
eventVolunteerGroupModel()) as ReturnType<typeof eventVolunteerGroupModel>; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { EventVolunteerGroup } from "../../models"; | ||
import type { EventVolunteerResolvers } from "../../types/generatedGraphQLTypes"; | ||
|
||
export const group: EventVolunteerResolvers["group"] = async (parent) => { | ||
return await EventVolunteerGroup.findOne({ | ||
_id: parent.groupId, | ||
}).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { User } from "../../models"; | ||
import type { EventVolunteerGroupResolvers } from "../../types/generatedGraphQLTypes"; | ||
|
||
export const creator: EventVolunteerGroupResolvers["creator"] = async ( | ||
parent, | ||
) => { | ||
return await User.findOne({ | ||
_id: parent.creatorId, | ||
}).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Event } from "../../models"; | ||
import type { EventVolunteerGroupResolvers } from "../../types/generatedGraphQLTypes"; | ||
|
||
export const event: EventVolunteerGroupResolvers["event"] = async (parent) => { | ||
return await Event.findOne({ | ||
_id: parent.eventId, | ||
}).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { EventVolunteerGroupResolvers } from "../../types/generatedGraphQLTypes"; | ||
import { leader } from "./leader"; | ||
import { creator } from "./creator"; | ||
import { event } from "./event"; | ||
|
||
export const EventVolunteerGroup: EventVolunteerGroupResolvers = { | ||
creator, | ||
leader, | ||
event, | ||
}; |
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,12 @@ | ||
import { User } from "../../models"; | ||
import type { InterfaceUser } from "../../models"; | ||
import type { EventVolunteerGroupResolvers } from "../../types/generatedGraphQLTypes"; | ||
|
||
export const leader: EventVolunteerGroupResolvers["leader"] = async ( | ||
parent, | ||
) => { | ||
const groupLeader = await User.findOne({ | ||
_id: parent.leaderId, | ||
}).lean(); | ||
return groupLeader as InterfaceUser; | ||
}; |
Oops, something went wrong.