diff --git a/server/models/coordinator.js b/server/models/coordinator.js index ced548c..666ed3b 100644 --- a/server/models/coordinator.js +++ b/server/models/coordinator.js @@ -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); diff --git a/server/models/importantDocument.js b/server/models/importantDocument.js new file mode 100644 index 0000000..30001a0 --- /dev/null +++ b/server/models/importantDocument.js @@ -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); diff --git a/server/schema/queries.js b/server/schema/queries.js index 2a79108..8e71c7a 100644 --- a/server/schema/queries.js +++ b/server/schema/queries.js @@ -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({ @@ -45,6 +48,13 @@ const query = new GraphQLObjectType({ return Coordinator.find({}); }, }, + ImportantDocuments: { + type: new GraphQLList(ImportantDocumentType), + args: {}, + resolve(parents, args){ + return ImportantDocument.find({}); + } + } }, }); diff --git a/server/schema/types.js b/server/schema/types.js index c5c317f..3b6bd13 100644 --- a/server/schema/types.js +++ b/server/schema/types.js @@ -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 }); }, }, }), @@ -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 }); }, }, }), @@ -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 }); }, }, }), @@ -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, };