prep/cook times and some fit and finish
This commit is contained in:
parent
a3b0fffe45
commit
9656888cb7
14 changed files with 141 additions and 46 deletions
|
@ -49,7 +49,7 @@ app.get("/backend/recipe/:id", async (req, res) => {
|
|||
try {
|
||||
const recipeQuery = db("recipes")
|
||||
.where("id", "=", id)
|
||||
.select("id", "name", "author", "cuisine", "stars");
|
||||
.select("id", "name", "author", "cuisine", "stars", "prep_minutes", "cook_minutes");
|
||||
|
||||
const ingredientsQuery = db
|
||||
.from("recipe_ingredients")
|
||||
|
@ -81,13 +81,15 @@ app.get("/backend/recipe/:id", async (req, res) => {
|
|||
|
||||
// ### ADD RECIPE ###
|
||||
app.post("/backend/add-recipe", async (req, res) => {
|
||||
const { name, author, cuisine, stars, ingredients, steps } = req.body;
|
||||
const { name, author, cuisine, stars, ingredients, steps, prep_minutes, cook_minutes } = req.body;
|
||||
try {
|
||||
const [id] = await db("recipes").insert(
|
||||
{
|
||||
name: name,
|
||||
author: author,
|
||||
cuisine: cuisine,
|
||||
prep_minutes: prep_minutes,
|
||||
cook_minutes: cook_minutes,
|
||||
stars: stars,
|
||||
},
|
||||
["id"],
|
||||
|
|
22
backend/migrations/20250728174922_add_times_recipes.js
Normal file
22
backend/migrations/20250728174922_add_times_recipes.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* @param { import("knex").Knex } knex
|
||||
* @returns { Promise<void> }
|
||||
*/
|
||||
exports.up = function (knex) {
|
||||
|
||||
return knex.schema.table('recipes', table => {
|
||||
table.integer('prep_minutes');
|
||||
table.integer('cook_minutes');
|
||||
})
|
||||
};
|
||||
|
||||
/**
|
||||
* @param { import("knex").Knex } knex
|
||||
* @returns { Promise<void> }
|
||||
*/
|
||||
exports.down = function (knex) {
|
||||
return knex.schema.table('recipes', table => {
|
||||
table.dropColumn('prep_minutes');
|
||||
table.dropColumn('cook_minutes')
|
||||
})
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue