This is the back-end for my project https://github.com/YIZHUANG/ideaManagement_frontend_reactjs
Build with ReactJs as front-end. Node.js, Knex as back-end, and postgresql as the database.
The reason that i don't refactor the massive chunk of codes in my route handlers is because i have decided that this is a different case, a different situation, it is easier to understand the logic of the code this way having everything displayed in front of you and for the good of whomever is gonna take over the project, other than dividing them into pieces.
/listData is the route I am using for getting a list of ideas with join operations, and yes! I know I should have named it better.
Knex do not support uppercase naming of the attributes / tables. Many errors will occur when you are trying to use knex.raw syntax,so try to keep them all lower case.
$ Make sure you have postresql installed, and set the postgresql/bin and lib folder to your environment path.
if you are using mariadb or mysql, fine! just remember to change your client type in knexfile.js file
$ npm install
#Rollback the database
$ knex migrate:rollback
knex migrate:latest
knex seed:run
$ npm run server
knexfile.js : where the database connection is , replace them with your own database configs.
server.js : where the port and main things are defined.
routes/featuresApi.js : all the routes that I am using in the front-end. (where I have the join operations and triggers)
$routes/deleteData.js and the rest of the files in this folder are for testing purposes with postman and for future usage perhaps.
db/migrations/20171205155213_create_users.js is the fine where I define the tables and attributes constraints all those stuff.
db/seeds/ the files in this folder are the inserted test data. You can also do these stuff manually with the database client. Or with postman
Functions:
display list of data.
add data. (when you add data, it will trigger another add data request automatically)
edit the data. (when you edit data, it will trigger another edit data request automatically)
delete the data.(Associated rows from other tables will be deleted as well due to onDelete('CASCADE'))