PeerTube/server/models/utils.ts

22 lines
394 B
TypeScript
Raw Normal View History

2016-12-11 14:50:51 -06:00
// Translate for example "-name" to [ 'name', 'DESC' ]
function getSort (value) {
let field
let direction
2016-08-16 15:31:45 -05:00
2016-12-11 14:50:51 -06:00
if (value.substring(0, 1) === '-') {
direction = 'DESC'
field = value.substring(1)
} else {
direction = 'ASC'
field = value
}
2016-08-16 15:31:45 -05:00
2016-12-11 14:50:51 -06:00
return [ field, direction ]
2016-08-16 15:31:45 -05:00
}
// ---------------------------------------------------------------------------
2017-05-15 15:22:03 -05:00
export {
getSort
}