Add GMU2016F semester data

parent 320b2aa8
This diff is collapsed.
This diff is collapsed.
......@@ -82,10 +82,16 @@ for (var i=0; i < jsonContents.length; i++) {
term_classes.push(c);
}
}
var term_classes_json = JSON.stringify(term_classes);
var semester = {
school: 'GMU',
semester: 'Fall 2016',
slug: 'GMU2016F',
classes: term_classes
}
var semesterJSON = JSON.stringify(semester);
try {
var result = term_classes_json;
var result = semesterJSON;
// write a JSON file.
var fs = require('fs');
fs.writeFile('classes2016.json', result, function (err) {
......
......@@ -4,7 +4,7 @@ var Schema = mongoose.Schema;
// create a schema
var semesterSchema = new Schema({
school: { type: String, required: true }
school: { type: String, required: true },
semester: { type: String, required: true },
slug: { type: String, required: true },
classes: [
......@@ -31,7 +31,7 @@ var semesterSchema = new Schema({
// the schema is useless so far
// we need to create a model using it
var Semester = mongoose.model('Semester', userSchema);
var Semester = mongoose.model('Semester', semesterSchema);
// make this available to our users in our Node applications
module.exports = Semester;
// grab the things we need
var mongoose = require('mongoose');
var Semester = require('../models/Semester');
var populateDB = function() {
console.log("test worked");
emptySemesters(); // NOTE: this is an asynchronous call
}
// Empty collections
// http://stackoverflow.com/questions/10081452/drop-database-with-mongoose
function emptySemesters() {
Semester.remove({}, handleEmptySemesters);
}
function handleEmptySemesters(err) {
if (err) { console.error('Database Error!', err) }
else{
console.log('semesters removed');
loadFiles();
}
}
function loadFiles() {
console.log('Test successful')
}
module.exports = populateDB;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment