]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/models/utils.ts
601811913d5d24dde4aedcd7486882638ab3ef86
[github/Chocobozzz/PeerTube.git] / server / models / utils.ts
1 // Translate for example "-name" to [ 'name', 'DESC' ]
2 function getSort (value) {
3 let field
4 let direction
5
6 if (value.substring(0, 1) === '-') {
7 direction = 'DESC'
8 field = value.substring(1)
9 } else {
10 direction = 'ASC'
11 field = value
12 }
13
14 return [ field, direction ]
15 }
16
17 // ---------------------------------------------------------------------------
18
19 export {
20 getSort
21 }