From e00a165ce22ebf8f353eae8a6c05ea471cf9dcec Mon Sep 17 00:00:00 2001 From: dbroqua Date: Thu, 11 Apr 2019 12:28:09 +0200 Subject: [PATCH] Updated default order for vegetables in types --- middleware/VegetableTypes.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/middleware/VegetableTypes.js b/middleware/VegetableTypes.js index 84d36be..61d74f4 100644 --- a/middleware/VegetableTypes.js +++ b/middleware/VegetableTypes.js @@ -1,4 +1,5 @@ -const vegetableTypes = require('../models').vegetableTypes +const models = require('../models') +const vegetableTypes = models.vegetableTypes class VegetableTypes { static getAll (req, callback) { @@ -6,7 +7,15 @@ class VegetableTypes { order: [ ['name', 'ASC'] ], - include: ['Vegetables'] + include: [{ + include: [{ + model: models.Vegetables, + as: 'Vegetables', + order: [ + ['name', 'ASC'] + ] + }] + }] }) .then(items => { if (!items) { @@ -34,7 +43,13 @@ class VegetableTypes { vegetableTypes.findById( req.params.vegetableTypesId, { - include: ['Vegetables'] + include: [{ + model: models.Vegetables, + as: 'Vegetables', + order: [ + ['name', 'ASC'] + ] + }] }) .then(item => { if (!item) {