Fehlerbehandlung bei null Werten in der Menge
This commit is contained in:
parent
482b476831
commit
86ac2f7ec8
2
app.js
2
app.js
|
@ -16,6 +16,7 @@ const dbhog = require('./dbhog')
|
||||||
|
|
||||||
const PORT = process.env.PORT || 4000;
|
const PORT = process.env.PORT || 4000;
|
||||||
|
|
||||||
|
var userRouter = require('./routes/users');
|
||||||
|
|
||||||
var indexRouter = require('./routes/index');
|
var indexRouter = require('./routes/index');
|
||||||
var valuelistRouter = require('./routes/valuelist');
|
var valuelistRouter = require('./routes/valuelist');
|
||||||
|
@ -57,6 +58,7 @@ app.use('/', indexRouter);
|
||||||
app.use('/wl', valuelistRouter);
|
app.use('/wl', valuelistRouter);
|
||||||
app.use('/vl', valuelistRouter);
|
app.use('/vl', valuelistRouter);
|
||||||
app.use('/recepies', recepieRouter);
|
app.use('/recepies', recepieRouter);
|
||||||
|
app.use('/users', userRouter);
|
||||||
|
|
||||||
app.use('/api/v1/person', personRouter);
|
app.use('/api/v1/person', personRouter);
|
||||||
app.use('/api/v1/schueler', schuelerRouter);
|
app.use('/api/v1/schueler', schuelerRouter);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// SQL-Class
|
// SQL-Class
|
||||||
// Author: Thomas Mack
|
// Author: Thomas Mack
|
||||||
|
|
||||||
const DEBUG = false;
|
const DEBUG = true;
|
||||||
|
|
||||||
const { Pool } = require('pg');
|
const { Pool } = require('pg');
|
||||||
const pool = new Pool({
|
const pool = new Pool({
|
||||||
|
|
|
@ -79,10 +79,19 @@ router.get('/:ingredientId', function(req, res, next) {
|
||||||
|
|
||||||
router.put('/:ingredientId', function(req, res, next) {
|
router.put('/:ingredientId', function(req, res, next) {
|
||||||
let recepieIngredient = req.body.recepieIngredients[0];
|
let recepieIngredient = req.body.recepieIngredients[0];
|
||||||
|
//console.log(recepieIngredient.menge>0);
|
||||||
|
let menge = null;
|
||||||
|
if (recepieIngredient.menge>0) {
|
||||||
|
menge = recepieIngredient.menge;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
menge = null;
|
||||||
|
}
|
||||||
|
|
||||||
let query = "UPDATE rezept_zutat set menge = $1, einheit = $2, zutat =$3, beschreibung =$4"+
|
let query = "UPDATE rezept_zutat set menge = $1, einheit = $2, zutat =$3, beschreibung =$4"+
|
||||||
" WHERE id = "+req.ingredientId +
|
" WHERE id = "+req.ingredientId +
|
||||||
" returning *";
|
" returning *";
|
||||||
let values = [recepieIngredient.menge, recepieIngredient.einheit, recepieIngredient.zutat, recepieIngredient.beschreibung];
|
let values = [menge, recepieIngredient.einheit, recepieIngredient.zutat, recepieIngredient.beschreibung];
|
||||||
|
|
||||||
if(DEBUG) console.log(query);
|
if(DEBUG) console.log(query);
|
||||||
req.db.query(query, values, (err, rs) => {
|
req.db.query(query, values, (err, rs) => {
|
||||||
|
|
Loading…
Reference in New Issue