From 0f06abc7afd69567a64bf51caec28740edb72f53 Mon Sep 17 00:00:00 2001 From: lilmocc Date: Tue, 20 Mar 2018 22:28:08 -0700 Subject: [PATCH] f this shit --- models/drinks.js | 16 ++++++++++++++++ models/drinks_ingredients.js | 12 ++++++++++++ models/ingredients.js | 4 ---- routes/api-routes.js | 35 ++++------------------------------- 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/models/drinks.js b/models/drinks.js index e69de29..95c27f1 100644 --- a/models/drinks.js +++ b/models/drinks.js @@ -0,0 +1,16 @@ +// Model of our POST table. Includes a title, body, and category columns. +// see sequelize docs for further info on Model Defintion +// http://docs.sequelizejs.com/manual/tutorial/models-definition.html + +module.exports = function(sequelize, DataTypes) { + var allDrinks = sequelize.define("Drinks", { + drink_id: { + type: DataTypes.INTEGER, + primaryKey: true + }, + drink_name: DataTypes.STRING, + glass_type: DataTypes.STRING + }); + + return allDrinks; +}; diff --git a/models/drinks_ingredients.js b/models/drinks_ingredients.js index e69de29..864378c 100644 --- a/models/drinks_ingredients.js +++ b/models/drinks_ingredients.js @@ -0,0 +1,12 @@ +module.exports = function(sequelize, DataTypes) { + var drinksIngredients = sequelize.define("Drinks_Ingredients", { + id: { + type: DataTypes.INTEGER, + primaryKey: true + }, + drink_id: DataTypes.INTEGER, + ingredient_id: DataTypes.INTEGER + }); + + return drinksIngredients; +}; diff --git a/models/ingredients.js b/models/ingredients.js index 085f7c9..2def1fe 100644 --- a/models/ingredients.js +++ b/models/ingredients.js @@ -1,7 +1,3 @@ -// Model of our POST table. Includes a title, body, and category columns. -// see sequelize docs for further info on Model Defintion -// http://docs.sequelizejs.com/manual/tutorial/models-definition.html - module.exports = function(sequelize, DataTypes) { var allIngredients = sequelize.define("Ingredients", { ingredient_id: { diff --git a/routes/api-routes.js b/routes/api-routes.js index 8c02eaa..2f3141b 100644 --- a/routes/api-routes.js +++ b/routes/api-routes.js @@ -7,40 +7,14 @@ var db = require("../models"); module.exports = function(app) { - // GET route for getting all of the posts - app.get("/api/ingredients/", function(req, res) { - db.allIngredients.findAll({}) +// GET route for getting all of the ingredients +app.get("/api/ingredients", function(req, res) { + db.Ingredients.findAll({}) .then(function(dbPost) { res.json(dbPost); }); - - db.allIngredients.findAll({}).then(function(result) { - res.send(result); - }) }); - - // // POST route for saving a new post - // app.post("/api/posts", function(req, res) { - // console.log(req.body); - // db.Post.create({ - // title: req.body.title, - // body: req.body.body, - // category: req.body.category - // }) - // .then(function(dbPost) { - // res.json(dbPost); - // }); - // }); - - // app.post("/api/ingredients", function(req, res) { - // var ingredients = req.body.ingredients; - // // console.log(userInput); - // console.log("ingredients: " + ingredients); - // - // - // }); - app.post("/api/ingredients", function(req, res) { var ingredients = req.body.ingredients; // console.log(userInput); @@ -54,11 +28,10 @@ app.post("/api/ingredients", function(req, res) { WHERE ingredients.ingredient_id IN ( ? ) \ )"; -debugger; db.sequelize.query(possibleDrinks, {replacements: ingredients}) .then(function(dbResults) { console.log(dbResults); - })// replace ingredients with userInput + }) // replace ingredients with userInput });