Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for ICS Database 2020 #42

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions server/models/coordinator.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ const coordinatorSchema = new Schema({
contact: Number,
email: String,
designation: String,
prefect: {
type: Schema.Types.ObjectId,
ref: 'prefect',
},
prefect: String
});

module.exports = mongoose.model('coordinator', coordinatorSchema);
8 changes: 8 additions & 0 deletions server/models/importantDocument.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const importantDocumentsSchema = new Schema({
title: String,
link: String,
});

module.exports = mongoose.model('importantdoc', importantDocumentsSchema);
10 changes: 10 additions & 0 deletions server/schema/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ const Mentor = require('../models/mentor');
const Mentee = require('../models/mentee');
const Coordinator = require('../models/coordinator');
const Prefect = require('../models/prefect');
const ImportantDocument = require('../models/importantDocument');

const {
CoordinatorType,
PrefectType,
MentorType,
MenteeType,
ImportantDocumentType,
} = require('./types');

const query = new GraphQLObjectType({
Expand Down Expand Up @@ -45,6 +48,13 @@ const query = new GraphQLObjectType({
return Coordinator.find({});
},
},
ImportantDocuments: {
type: new GraphQLList(ImportantDocumentType),
args: {},
resolve(parents, args){
return ImportantDocument.find({});
}
}
},
});

Expand Down
34 changes: 22 additions & 12 deletions server/schema/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ const CoordinatorType = new GraphQLObjectType({
fields: () => ({
id: { type: GraphQLID },
name: { type: GraphQLString },
contact: { type: GraphQLInt },
contact: { type: GraphQLString },
rollNumber: { type: GraphQLString },
email: { type: GraphQLString },
designation: { type: GraphQLString },
prefect: { type: GraphQLID },
prefect: { type: GraphQLString },
prefectDetails: {
type: PrefectType,
resolve(parent, args) {
return Prefect.findById(parent.prefect);
return Prefect.findOne({ rollNumber: parent.prefect });
},
},
}),
Expand All @@ -36,14 +36,14 @@ const PrefectType = new GraphQLObjectType({
fields: () => ({
id: { type: GraphQLID },
name: { type: GraphQLString },
contact: { type: GraphQLInt },
contact: { type: GraphQLString },
email: { type: GraphQLString },
rollNumber: { type: GraphQLString },
coordinator: { type: GraphQLID },
coordinator: { type: GraphQLString },
coordinatorDetails: {
type: CoordinatorType,
resolve(parent, args) {
return Coordinator.findById(parent.coordinator);
return Coordinator.findOne({ rollNumber: parent.coordinator });
},
},
}),
Expand All @@ -55,19 +55,19 @@ const MentorType = new GraphQLObjectType({
id: { type: GraphQLID },
name: { type: GraphQLString },
rollNumber: { type: GraphQLString },
contact: { type: GraphQLInt },
contact: { type: GraphQLString },
email: { type: GraphQLString },
prefect: { type: GraphQLID },
prefect: { type: GraphQLString },
prefectDetails: {
type: PrefectType,
resolve(parent, args) {
return Prefect.findById(parent.prefect);
return Prefect.findOne({ rollNumber: parent.prefect });
},
},
mentees: {
type: new GraphQLList(MenteeType),
resolve(parent, args) {
return Mentee.find({ mentor: parent.id });
return Mentee.find({ mentor: parent.rollNumber });
},
},
}),
Expand All @@ -79,20 +79,30 @@ const MenteeType = new GraphQLObjectType({
id: { type: GraphQLID },
name: { type: GraphQLString },
rollNumber: { type: GraphQLString },
contact: { type: GraphQLInt },
contact: { type: GraphQLString },
email: { type: GraphQLString },
mentor: {
type: MentorType,
resolve(parent, args) {
return Mentor.findById(parent.mentor);
return Mentor.findOne({ rollNumber: parent.mentor });
},
},
}),
});

const ImportantDocumentType = new GraphQLObjectType({
name: 'ImportantDocuments',
fields: () => ({
id: {type: GraphQLID},
title: {type: GraphQLString},
link: {type: GraphQLString},
})
})

module.exports = {
CoordinatorType,
PrefectType,
MentorType,
MenteeType,
ImportantDocumentType,
};