From 33054cfa4964f0553661871b4ad41e59d49b9f89 Mon Sep 17 00:00:00 2001 From: DesignrKnight Date: Thu, 10 Dec 2020 23:21:46 +0530 Subject: [PATCH 1/2] Update for ICS Database 2020 Link Types by Roll Number instead of Roll Number --- server/models/coordinator.js | 5 +---- server/schema/types.js | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 16 deletions(-) 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/schema/types.js b/server/schema/types.js index c5c317f..e0f999a 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,12 +79,12 @@ 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 }); }, }, }), From 93cf1708a283276a3591c1d98e511d0f49cc8f76 Mon Sep 17 00:00:00 2001 From: DesignrKnight Date: Sun, 13 Dec 2020 01:30:09 +0530 Subject: [PATCH 2/2] Add Imp Docs to GraphQL Query --- server/models/importantDocument.js | 8 ++++++++ server/schema/queries.js | 10 ++++++++++ server/schema/types.js | 10 ++++++++++ 3 files changed, 28 insertions(+) create mode 100644 server/models/importantDocument.js 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 e0f999a..3b6bd13 100644 --- a/server/schema/types.js +++ b/server/schema/types.js @@ -90,9 +90,19 @@ const MenteeType = new GraphQLObjectType({ }), }); +const ImportantDocumentType = new GraphQLObjectType({ + name: 'ImportantDocuments', + fields: () => ({ + id: {type: GraphQLID}, + title: {type: GraphQLString}, + link: {type: GraphQLString}, + }) +}) + module.exports = { CoordinatorType, PrefectType, MentorType, MenteeType, + ImportantDocumentType, };