Skip to content

Instantly share code, notes, and snippets.

@roniewill
Created February 19, 2020 18:24
Show Gist options
  • Select an option

  • Save roniewill/d096eba77c7e1299b011a6df055c3c7b to your computer and use it in GitHub Desktop.

Select an option

Save roniewill/d096eba77c7e1299b011a6df055c3c7b to your computer and use it in GitHub Desktop.
function dataImport(db, callback) {
var students = db.collection('students');
var courses = db.collection('courses');
var instructors = db.collection('instructors');
// create student records
students.insertMany([
{
"_id": "john.shore",
"name": {"first": "John", "last": "Shore"},
"email": "john.shore@gmail.com",
"major": "Electrical Engineering"
},
{"_id": "jeff", "name": {"first": "Jeff", "last": "Holland"}, "email": "jeff@yahoo.com", "major": "Business"},
{
"_id": "scott",
"name": {"first": "Scott", "last": "Mills"},
"email": "scott@hotmail.com",
"major": "Humanities/Art"
},
{
"_id": "rcotter",
"name": {"first": "Ray", "last": "Cotter"},
"email": "rcotter@msn.com",
"major": "Computer Science"
},
{
"_id": "lee2331",
"name": {"first": "Lee", "last": "Aldwell"},
"email": "lee2331@aol.com",
"major": "Graphic Design"
}
], function (err,result) {
courses.insertMany([
{
"_id": "HIST-1010",
"name": "History of the World 1010",
"description": "A bunch of really interesting things that actually happened",
"students": ["scott", "john.shore"],
"ratings": [3, 5, 4, 5, 4, 4, 2, 4]
},
{
"_id": "ENGCOMP-1010",
"name": "English Composition 1010",
"description": "If you can't write well, you've got nothing!",
"students": ["scott", "lee2331", "rcotter", "john.shore", "jeff"],
"ratings": [4, 4, 5, 4, 5, 1, 5]
},
{
"_id": "ART-1050",
"name": "Artistic Interpretation 1050",
"description": "Discover your inner beholder",
"students": ["rcotter", "scott", "jeff"],
"ratings": [3, 4, 3, 4, 4, 3, 4, 4]
}
], function (err, result) {
instructors.insertMany([
{
"_id": "wally.r.binns",
"name": {"first": "Wally", "middle": "r", "last": "Binns"},
"email": "wally.r.binns@ssu.edu",
"bio": "I was born in the middle of my mother's doctoral dissertation on Faraday Cage isolation. I've been an academic ever since...",
"publications": [{
"title": "Inverted Celestial Poetry",
"source": "http://www.pubcentral.com/poetry/inverted-celestial-poetry"
}],
"courses": ["ENGLIT-2500"]
},
{
"_id": "gerald.waterford.iii",
"name": {"first": "Gerald", "last": "Waterford", "suffix": "III"},
"email": "gerald.waterford.iii@ssu.edu",
"bio": "My father's father was a great man. My father, not so much. I am restoring the family honor.",
"publications": [{
"title": "Grow, grow, little Dandelion",
"source": "http://www.hopefulstories.com/my-dandelion"
}, {"title": "The teapot and the spoon", "source": "http://www.dishsoap.com/teapot-spoon"}],
"courses": ["ENGCOMP-1010", "HIST-1010"]
},
{
"_id": "kim.b",
"name": {"prefix": "Mrs.", "first": "Kim", "last": "Binnley"},
"email": "kim.b@ssu.edu",
"bio": "My mother told me 'Don't let those dopes push you around'. My life has been a constant struggle against dopeness ever since. Sigh...",
"publications": [],
"courses": ["ART-1050"]
}
], function (err,result) {
callback();
});
});
});
}
module.exports = dataImport;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment