Updated default order
This commit is contained in:
parent
c6b8219d1e
commit
dc27bb9f08
1 changed files with 22 additions and 1 deletions
|
@ -20,7 +20,28 @@ class VegetableTypes {
|
||||||
callback(new Error('No vegetable type found'), 204)
|
callback(new Error('No vegetable type found'), 204)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
callback(null, items)
|
|
||||||
|
let res = []
|
||||||
|
|
||||||
|
for (let i = 0; i < items.rows.length; i += 1) {
|
||||||
|
let type = items[i].rows.toJSON()
|
||||||
|
let vegetables = []
|
||||||
|
|
||||||
|
for (let j = 0; j < type.Vegetables.length; j += 1) {
|
||||||
|
let k = 0
|
||||||
|
for (k = 0; k < vegetables.length; k += 1) {
|
||||||
|
if (type.Vegetables[j].name < vegetables[k]) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vegetables.splice(k, 0, type.Vegetables[j])
|
||||||
|
}
|
||||||
|
type.Vegetables = vegetables
|
||||||
|
res.push(type)
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, { count: items.count, rows: res })
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
callback(e, null)
|
callback(e, null)
|
||||||
|
|
Loading…
Reference in a new issue