Skip to content

Commit

Permalink
f this shit
Browse files Browse the repository at this point in the history
  • Loading branch information
lilmocc committed Mar 21, 2018
1 parent c1331cc commit 0f06abc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 35 deletions.
16 changes: 16 additions & 0 deletions 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;
};
12 changes: 12 additions & 0 deletions 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;
};
4 changes: 0 additions & 4 deletions 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: {
Expand Down
35 changes: 4 additions & 31 deletions routes/api-routes.js
Expand Up @@ -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);
Expand All @@ -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

});

Expand Down

0 comments on commit 0f06abc

Please sign in to comment.