Fixed bug

This commit is contained in:
dbroqua 2019-04-11 13:17:39 +02:00
parent b2cccada23
commit 38aff94e26

View file

@ -2,7 +2,7 @@ const models = require('../models')
const vegetableTypes = models.vegetableTypes const vegetableTypes = models.vegetableTypes
class VegetableTypes { class VegetableTypes {
static getAll(req, callback) { static getAll (req, callback) {
vegetableTypes.findAndCountAll({ vegetableTypes.findAndCountAll({
order: [ order: [
['name', 'ASC'] ['name', 'ASC']
@ -30,7 +30,7 @@ class VegetableTypes {
for (let j = 0; j < type.Vegetables.length; j += 1) { for (let j = 0; j < type.Vegetables.length; j += 1) {
let k = 0 let k = 0
for (k = 0; k < vegetables.length; k += 1) { for (k = 0; k < vegetables.length; k += 1) {
if (type.Vegetables[j].name < vegetables[k]) { if (type.Vegetables[j].name < vegetables[k].name) {
console.log('Break at:', k) console.log('Break at:', k)
break break
} }
@ -50,7 +50,7 @@ class VegetableTypes {
}) })
} }
createOne(req, callback) { createOne (req, callback) {
vegetableTypes.create(req.body) vegetableTypes.create(req.body)
.then(item => { .then(item => {
callback(null, item) callback(null, item)
@ -60,7 +60,7 @@ class VegetableTypes {
}) })
} }
static getOne(req, callback) { static getOne (req, callback) {
vegetableTypes.findById( vegetableTypes.findById(
req.params.vegetableTypesId, req.params.vegetableTypesId,
{ {
@ -84,7 +84,7 @@ class VegetableTypes {
}) })
} }
patchOne(req, callback) { patchOne (req, callback) {
VegetableTypes.getOne(req, (err, item) => { VegetableTypes.getOne(req, (err, item) => {
if (err) { if (err) {
callback(err, item) callback(err, item)
@ -101,7 +101,7 @@ class VegetableTypes {
}) })
} }
deleteOne(req, callback) { deleteOne (req, callback) {
VegetableTypes.getOne(req, (err, item) => { VegetableTypes.getOne(req, (err, item) => {
if (err) { if (err) {
callback(err, item) callback(err, item)