-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render mock data #40
Open
Heathercoraje
wants to merge
10
commits into
master
Choose a base branch
from
render-mock-data
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Render mock data #40
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0db3649
mock data rendering
c6afe13
[WIP] render mock data in /career
9a5b019
building data
8816220
render mock data
20b5502
render mock data
d42cd3c
solves merge conflicts
cfa6303
adds render error page to career.js
1ec5cf3
changes to err for consistency
2c6525f
solves merge conflicts
130b439
removes body-parser
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,38 @@ | ||
const career = require('./career_model.js'); | ||
const db = require('./db_connection.js'); | ||
const careers = require('./seed_data.js'); | ||
// const mongoose = require('mongoose'); | ||
const mongoose = require('mongoose'); | ||
|
||
db.once('open', () => { | ||
console.log('we are connected to DB'); | ||
career.collection.drop(); // once app is open, drop schema career | ||
|
||
careers.forEach((career) => { | ||
career.save((error, result) => { | ||
if (error) { | ||
// render error hbs | ||
return console.log(error); | ||
} | ||
}); | ||
var dataLength = 0; | ||
for (var i = 0; i < careers.length; i++) { | ||
careers[i].save((error, result) => { | ||
if (error) { | ||
console.log(error); | ||
} else { | ||
dataLength++; | ||
console.log('adding to db'); | ||
if (dataLength === careers.length) { | ||
exit(); | ||
console.log('done'); | ||
} // no else | ||
} | ||
}); | ||
}); | ||
|
||
// not sure if we need this | ||
// function exit () { | ||
} | ||
function exit () { | ||
mongoose.disconnect(); | ||
} | ||
// | ||
// | ||
// db.once('open', () => { | ||
// console.log('we are connected to DB'); | ||
// Career.collection.drop(); // once app is open, drop schema career | ||
// | ||
// careers.forEach((career) => { | ||
// career.save((error, result) => { | ||
// if (error) { | ||
// return console.log(error); | ||
// } | ||
// console.log(result); | ||
// console.log('add one schema to DB'); | ||
// }); | ||
// }); | ||
// mongoose.disconnect(); | ||
// } | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
const Career = require('./../../database/career_model.js'); | ||
|
||
module.exports = (req, res) => { | ||
res.render('career'); | ||
Career.find({}, (error, result) => { | ||
if (error) { | ||
console.log('Error with rendering data', error); | ||
} else { | ||
res.render('career', { career: result }); | ||
console.log('this is the result:', result); | ||
console.log(); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<section class="career-card"> | ||
|
||
<h1>We are the amazing GERMS!</h1> | ||
<h2 class="career-title">{{ career.title }}</h2> | ||
<image class="career-icon" src="{{ career.icon }}" alt="{{ career.title }}"> | ||
<p class="career-tagline"> {{ career.tagline }}</p> | ||
<h2 class="career-title">{{ career[0].title }}</h2> | ||
<image class="career-icon" src="{{ this.icon }}" alt="{{ this.title }}"> | ||
<p class="career-tagline"> {{ this.tagline }}</p> | ||
|
||
</section> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some research and found out that save is a wrapper for insert and update, see this. If this is true then we could get rid of the for loop and use insertMany() instead.