add mongoose and migrations [closes #11]#12
add mongoose and migrations [closes #11]#12shakalee14 wants to merge 3 commits intoGuildCrafts:masterfrom Moniarchy:11-add-mongoose-migrations
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.
@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.
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.
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.
Was this comment addressed? Is this file still needed?
There was a problem hiding this comment.
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.
@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.
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.
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.
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.
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.
Have we officially decided on Mongoose? Would love to here why we decided to use this lib.
There was a problem hiding this comment.
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.
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.
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); |
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.
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.
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.
@shakalee14 @Moniarchy change requests in line
README.md
Outdated
|
|
||
| ## Testing | ||
| TBD No newline at end of file | ||
| <<<<<<< HEAD |
There was a problem hiding this comment.
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.
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.
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.
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.
Does create take parameters? If it does, does this work?
There was a problem hiding this comment.
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.
| @@ -70,4 +70,4 @@ app.use(function(err, req, res, next) { | |||
| }); | |||
|
|
|||