From cfd11b481be1fdd982fcaa43fb070d8d87df5702 Mon Sep 17 00:00:00 2001 From: freearhey Date: Wed, 10 Feb 2021 17:03:42 +0300 Subject: [PATCH] Update db.js --- scripts/db.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/db.js b/scripts/db.js index 8b840f85ae..b69483984d 100644 --- a/scripts/db.js +++ b/scripts/db.js @@ -40,9 +40,13 @@ db.channels = { return this.list.filter(channel => channel.countries.map(c => c.code).includes(country.code)) }, forLanguage(language) { + if (!language.code) return this.list.filter(channel => !channel.languages.length) + return this.list.filter(channel => channel.languages.map(c => c.code).includes(language.code)) }, forCategory(category) { + if (!category.id) return this.list.filter(channel => !channel.category) + return this.list.filter(channel => channel.category.toLowerCase() === category.id) }, count() { @@ -89,6 +93,11 @@ db.languages = { }, count() { return this.list.length + }, + sortBy(fields) { + this.list = utils.sortBy(this.list, fields) + + return this } }