cmda-bt / be-course-17-18

🎓 Backend · 2017-2018 · Curriculum and Syllabus 💾
Other
47 stars 19 forks source link

Storage assignment #555

Closed Murderlon closed 6 years ago

Murderlon commented 6 years ago

Everything should be in there though I didn't have to time to refactor some things for better error handling.

I continue to dislike SQL queries and especially the arbitrary boiler plate code for pooling connections across routes with mysql.

https://github.com/Murderlon/shelter

rijkvanzanten commented 6 years ago

Hey @Murderlon!

Do you have a database dump and some install instructions so I can check it out? Thx :)

wooorm commented 6 years ago

@Murderlon Ping!

Murderlon commented 6 years ago

MySQL was set up using Docker through Kitematic.

screen shot 2018-03-25 at 17 45 16

I used a script to populate the db.

require('dotenv').config();
const pool = require('./server/mysql');
const data = require('./db/data.json');

pool.getConnection((err, connection) => {
    data.map(({id, ...animal}) => {
      connection.query('INSERT INTO animal SET ?', animal, (err, done) => console.log({err, done}));
    })
    connection.release();
    // Handle error after the release.
    if (err) throw err;
  });

Which basicly resulted in a non-relational copy of the db in MySQL. I know, the assignment was to make it relational but unfortunately I didn't have a lot of time when I made this.

screen shot 2018-03-25 at 17 47 41
rijkvanzanten commented 6 years ago

This is unfortunately not enough information to get up and running. I still don't know what's supposed to go in your .dotenv files or how to replicate your setup..

Even with trying to get it up and running by manually figuring out the .env contents, I get an unhandled error as soon as I try to open the page

~/Development/shelter [master]
☛  npm start

> shelter@1.0.0 start /Users/rijkvanzanten/Development/shelter
> node server

listening on http:localhost:1902
/Users/rijkvanzanten/Development/shelter/server/index.js:28
    connection.query('SELECT * from animal', done);
               ^

I also don't know how you setup your database (what columns / datatypes / etc), and as you already mentioned:

I know, the assignment was to make it relational but unfortunately I didn't have a lot of time when I made this.

I continue to dislike SQL queries and especially the arbitrary boiler plate code for pooling connections across routes with mysql.

Check out Bookshelf and alleviate the pain