Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello I need help with one assignment is already on the last part:Message from professor:For getCoursesBySubject service, you'll first want to import the courses module

Hello I need help with one assignment is already on the last part:Message from professor:For getCoursesBySubject service, you'll first want to import the courses module from models. This will provide you with an object with a find method that you can use to filter the list of all courses by the subject input gotten from the URL parameter. To do this, you can call find on the imported object and pass it a function that when receiving a course object like the zeroth one in the Array in courses.json:{"add":"","textbooks":"","course_code":"ACC 260002","name":"Accounting I","type":"","faculty":"Bier, Diana","seats_open":"1/25","status":"Open","schedule":"TR 10:40 AM-12:05 PM,9/7/2022-12/20/2022; Main Campus, Adelaide B. Wilbur Arts Center","credits":"3.00","begin_date":"9/7/2022","end_date":"12/20/2022"}returns true when this object's course_code property starts with the subject input. Remember that since find is asynchronous, you'll need to use an await. You can then return this result. This can all be done in one line. Let me know if you have any questions about this. I can review this function when you're done, and then we can move to the getCoursesByGenEdCategory functionThis is what my code is lookig like:class CourseServices{ async getCoursesBySubject(subject){ return subject; } async getCoursesByGenEdCategory(category){ return category; }}module.exports= new CourseServices();These are the instructions of what to do:.For the getCoursesBySubject service, now make it an async function because you'll need to await the result from the Model class. Import the courses model. Change the implementation return the result of calling the find method to get all courses whose course code starts with the given subject. Note that the return statement will need to have an await since the function is asynchronous. We'll also want to do something similar for the general education courses but there we'll only be getting the general education courses which are currently offered next semester. So, first we'll use the result of calling await to get all the courses and form a Set of the codes. Then we'll return all gened courses in that category whose codes are in this set.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions