-
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
Initial db setup #27
Initial db setup #27
Conversation
pull the latest master and merge it with this branch |
Codecov Report
@@ Coverage Diff @@
## master #27 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 1 1
Lines 6 6
=====================================
Hits 6 6 Continue to review full report at Codecov.
|
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.
Looks great
database/db_build.js
Outdated
for (let i = 0; i < careers.length; i++) { | ||
careers[i].save((error, result) => { | ||
if (error) { | ||
console.log(error); |
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.
error handling?
relates #16
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.
You guys are also setting up the database files as if this is postgres which is not.
also maybe rename src/index.js to something else?
database/db_build.js
Outdated
career.collection.drop(); // once app is open, drop schema career | ||
|
||
let dataLength = 0; | ||
for (let i = 0; i < careers.length; i++) { |
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.
use a forEach instead cause then you won't need the dataLength var
database/db_build.js
Outdated
|
||
db.once('open', () => { | ||
console.log('we are connected to DB'); | ||
career.collection.drop(); // once app is open, drop schema career |
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.
why ?
database/db_build.js
Outdated
}); | ||
} | ||
|
||
function exit () { |
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.
arrow function here please
src/index.js
Outdated
db.once('open', function () { | ||
console.log('connected to DB'); | ||
app.listen(app.get('port'), () => { | ||
console.log('Magic happens on port 8181!'); |
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.
the original one was a bit better, cause what if you wanted to change the port ???
also i would do
process.env.PORT || app.get('port')
for heroku setup
require('env2')('./congif.env'); | ||
|
||
const db = mongoose.connection; | ||
mongoose.connect(process.env.MONGODB_URI, { |
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.
do we need a whole different file for this ??
why not justg add it to the src/index.js ( which should be renamed )
#16
Create files database yet still needs to add codes in app.js to build db properly.