Update db.js

This commit is contained in:
freearhey 2021-02-10 17:03:42 +03:00
parent 60f9d3867f
commit cfd11b481b
1 changed files with 9 additions and 0 deletions

View File

@ -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
}
}