Skip to content

Commit

Permalink
reverted db changes, attempted to remove sqlitefile
Browse files Browse the repository at this point in the history
  • Loading branch information
LaikaFusion committed Oct 2, 2018
1 parent e3fdda0 commit 3c99c3d
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
/backend/node_modules
/frontend/node_modules
/frontend/node_modules
*.sqlite3
4 changes: 3 additions & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
YOU NEED TO CREATE THE DATABASE BEFORE THE SERVER IS STARTED

ENDPOINTS

localhost:3000/sky/view
Expand All @@ -7,7 +9,7 @@ localhost:3000/sky
Will take in a color as a hex value and and generate a list of URLS matching that color, then sends back a random URL from that list.

localhost:3000/sky/add
lol


localhost:3000/sky/:id
Will return the specific sky with that ID
Expand Down
4 changes: 2 additions & 2 deletions backend/db/migrations/20180928114941_sky_table.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
exports.up = function(knex, Promise) {
return knex.schema.createTable("sky_table", function(sky) {
return knex.schema.createTable("sky", function(sky) {
sky.increments();

sky.string("color1").notNullable();
Expand All @@ -13,5 +13,5 @@ exports.up = function(knex, Promise) {
};

exports.down = function(knex, Promise) {
return knex.schema.dropTableIfExists("sky_table");
return knex.schema.dropTableIfExists("sky");
};
Empty file removed backend/db/sky.sqlite3
Empty file.
Binary file removed backend/db/sky_table.sqlite3
Binary file not shown.
11 changes: 5 additions & 6 deletions backend/dbHelpers/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,29 @@ const db = knex(config.development);

module.exports = {
getSkies: () => {
return db("sky_table").then(results => {
return db("sky").then(results => {
return results;
});
},

getSky: id => {
return db("sky_table")
return db("sky")
.where({ id: id })
.first()
.then(results => {
return results;
});
},
getSkyByColor: colorHex =>{
return db("sky_table").select('url').where({color1: colorHex}).orWhere({color2:colorHex}).orWhere({color3:colorHex}).orWhere({color4:colorHex}).orWhere({color5:colorHex});
return db("sky").select('url').where({color1: colorHex}).orWhere({color2:colorHex}).orWhere({color3:colorHex}).orWhere({color4:colorHex}).orWhere({color5:colorHex});

},
getAllColors: ()=>{
return db("sky_table").select('color1','color2','color3','color4','color5')
return db("sky").select('color1','color2','color3','color4','color5')
},

addSky: ({ skyObj }) => {
return db("sky_table").insert({

return db("sky").insert({
color1: skyObj.color1,
color2: skyObj.color2,
color3: skyObj.color3,
Expand Down
5 changes: 4 additions & 1 deletion backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ app.post("/imgur", async (req, res) => {
return;
});
});

app.get("/colorrefresh", (req, res) => {
colorCompare.getAllColors();
res.send("Refresh");
});
app.get("/", (req, res) => {
res.send("Wrong endpoint");
});
Expand Down
2 changes: 1 addition & 1 deletion backend/knexfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
development: {
client: "sqlite3",
connection: {
filename: "./db/sky_table.sqlite3"
filename: "./db/sky.sqlite3"
},
seeds: {
directory: "./db/seeds"
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/Result/Result.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class Result extends Component {
return (
<div className="App">
<div className="result"></div>
::
{this.state.result}
</div>
);
Expand Down

0 comments on commit 3c99c3d

Please sign in to comment.