Starting from:
$30

$24

Assignment Module 13 Chapter 8 Mongo Solution

In this assignment you will work with loading data from a csv file into a mongodb and then building a web application that will let the user make queries of the data set. The data is an open data set measuring student test performance.




Skeleton




The skeleton for this project is in my public git file at https://gitlab.csi.miamioh.edu/campbest/cse270e-




campbest-public (https://gitlab.csi.miamioh.edu/campbest/cse270e-campbest-public) . I suggest you clone this to your ubuntu instance (not in your working directory but under /home/ubuntu) and the copy the files to your own repository working copy.




Load the data




Create a new mongodb called StudentPerformanceData using the mongo cli.




Copy over the skeleton Assignment-13 directory to your working copy.



In Assignment-13 the data is in a folder called data.



Inside this directory download the file StudentPerformanceData.csv



Using the mongoose schema module, create a nodejs program called loadData.js that will read in the StudentPerformanceData.csv and populate the mongodb. Here is the schema that I used:



var studentDataSchema = new mongoose.Schema({ gender: String,




race: String,




parentEducation: String,




lunch: String,




testPrep: String,




math: String,




reading: String,




writing: String });







FYI: You will need to read in the file using the npm module file and I also used the npm module csv to parse the csv record.
Complete the Data Model for the express applica on



Look over the express code and see how the data model is used. The name of the exported functions (which all return promises) are at the end of the file data/StudentDataModel.js



A data model is simply a js program that handles all interactions with the data. The functions in this program will be called by express to get and populate the various data elements for the Express application.



You will be building a node module, so all functions you want to make available to world will need to be exported via the exports (https://www.sitepoint.com/understanding-module-exports-exports-



node-js/) method.




All mongodb calls should be via the mongoose module



Functions that you will need to create are: Remember these functions will use a callback to return the actual data.



addStudent(record)



this method will add a record to the mongodb



close



close the mongodb connection



clear



Calls the mongodb drop function to clear out existing records



getStats



This method will return a datastructure will all the statistics the view is looking to display. I used a whole series of awaits to get each statistic. This method takes in 3 parameters, math, reading and writing and uses the query to select only those records whose scores are greater than the input values.



Use the mongo query logic (https://docs.mongodb.com/manual/reference/operator/query/) :



When done the existing express code should work with your datamodel. I don't believe you should have to modify any of the app.js or view code.




Video Discussing Solu~on













Submit:




Run this application on port 3013







submit links to the running application and to your git repository.






More products