-
Notifications
You must be signed in to change notification settings - Fork 8
add mongoose and migrations [closes #11] #12
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
base: master
Are you sure you want to change the base?
add mongoose and migrations [closes #11] #12
Conversation
shakalee14
commented
Nov 1, 2016
- create add_user table via migrations
|
hey @jrob8577 - looking for feedback. wrote instructions in migrations.md |
jrobcodes
left a comment
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.
@shakalee14 @Moniarchy @jamestewartjr @pllearns Changes requested. Also, could we get a PR for just the infrastructure so that I do not need to look through files that are not changing from PR to PR?
.gitignore
Outdated
| node_modules | ||
| yarn-error.log | ||
| npm-debug.log | ||
| yarn.lock |
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.
yarn.lock should not be in the gitignore file...
migrations.md
Outdated
| @@ -0,0 +1,11 @@ | |||
| If a contributor wants to change the schema, they must create a migration. Current migrations have been created with the following commands: | |||
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.
There's a lot of instruction in this file that is not specifically concerned with migrations. I would prefer to make this more concise, and place it in the CONTRIBUTING.md file, similar to the floworky approach.
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.
Was this comment addressed? Is this file still needed?
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.
We deleted it but it must have come back during a rebase without our realizing it. When we push up again it'll be gone.
|
@jrob8577 we addressed your changes! thanks. |
jrobcodes
left a comment
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.
@shakalee14 @jamestewartjr @pllearns @Moniarchy Comments inline
README.md
Outdated
| ## Setting up Development Environment | ||
|
|
||
| A mongodb database named lizardboard must be created prior to starting the application for the first time. | ||
| - Brew install mongodb |
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.
brew should be lower case
README.md
Outdated
|
|
||
| A mongodb database named lizardboard must be created prior to starting the application for the first time. | ||
| - Brew install mongodb | ||
| - Yarn install |
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.
yarn should be lower case. We should probably also insert a command to install yarn globally (before brew install mongodb maybe?).
README.md
Outdated
| - Brew install mongodb | ||
| - Yarn install | ||
| - Run `mongod` command on one tab to open up the database server | ||
| - Run `mongo` command on another tab to open up the MongoDB shell |
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.
Remove this line; running the mongo shell is not a necessary step to setting up the dev environment.
README.md
Outdated
| A mongodb database named lizardboard must be created prior to starting the application for the first time. | ||
| - Brew install mongodb | ||
| - Yarn install | ||
| - Run `mongod` command on one tab to open up the database server |
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 think we can remove this command as well - installing the DB implies that is is running for the project to work, IMHO. If you disagree, I think I'd rather see this as Ensure mongo is running, maybe after the brew command?
README.md
Outdated
|
|
||
| ### Database | ||
| - [Mongodb](https://docs.mongodb.com/) | ||
| -[Mongoose](http://mongoosejs.com/docs/guide.html) |
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.
Have we officially decided on Mongoose? Would love to here why we decided to use this lib.
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.
It's the most popular and supported ORM for Mongo, based on our research.
| @@ -0,0 +1,9 @@ | |||
| const express = require('express'); | |||
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.
Let's get rid of unused routes in the initial submission
server/index.js
Outdated
| // Use connect method to connect to the Server | ||
| MongoClient.connect(url, function(err, db) { | ||
| assert.equal(null, err); | ||
| console.log("Connected correctly to server"); |
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.
This is less interesting than if an error occurs - I would remove this and only output something if a failure occurs. As well, the server probably shouldn't start up unless we manage to connect to the database, so this is probably the wrong place for this code.
server/index.js
Outdated
| const url = 'mongodb://127.0.0.1:27017/lizardboard'; | ||
| // Use connect method to connect to the Server | ||
| MongoClient.connect(url, function(err, db) { | ||
| assert.equal(null, err); |
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 assert.equal?
server/index.js
Outdated
| , assert = require('assert'); | ||
|
|
||
| // Connection URL | ||
| const url = 'mongodb://127.0.0.1:27017/lizardboard'; |
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.
We should move this const and db connection logic into its own module.
server/index.js
Outdated
| assert.equal(null, err); | ||
| console.log("Connected correctly to server"); | ||
|
|
||
| db.close(); |
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 are we closing the db?
- create add_user table via migrations - addressed jrobs comments, created contributing md and added info to readme
jrobcodes
left a comment
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.
@shakalee14 @Moniarchy change requests in line
README.md
Outdated
|
|
||
| ## Testing | ||
| TBD | ||
| <<<<<<< HEAD |
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.
There's a merge conflict in here.
database.js
Outdated
| @@ -0,0 +1,9 @@ | |||
| const db = 'mongodb://localhost/lizardboard' | |||
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.
What is this const used for?
database.js
Outdated
| @@ -0,0 +1,9 @@ | |||
| const db = 'mongodb://localhost/lizardboard' | |||
| const url = 'mongodb://127.0.0.1:27017/lizardboard'; | |||
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.
Let's make this upper case URL, and maybe name it to be more specific (DATABASE_URL perhaps?)
database.js
Outdated
| const url = 'mongodb://127.0.0.1:27017/lizardboard'; | ||
| const MongoClient = require('mongodb').MongoClient, assert = require('assert'); | ||
|
|
||
| MongoClient.connect(url, (err, res, db) => { |
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 think we need to make this a promise and export the creation of the promise as a function - otherwise we can't guarantee that we have successfully connected to the database when the server starts...
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "start": "nodemon ./bin/www" | ||
| "start": "nodemon ./bin/www", | ||
| "migration:create": "node_modules/.bin/migrate -d mongodb://localhost:27017/lizardboard create", |
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.
Does create take parameters? If it does, does this work?
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.
Yes, it does. Are there any specific changes you would like to see? We haven't had trouble with running this script. In CONTRIBUTING.md there are further instructions for using this script.
| 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.
Remove extra new line