]>
Commit | Line | Data |
---|---|---|
feb4bdfd | 1 | // Translate for example "-name" to [ 'name', 'DESC' ] |
69818c93 C |
2 | function getSort (value: string) { |
3 | let field: string | |
4 | let direction: 'ASC' | 'DESC' | |
5c39adb7 | 5 | |
feb4bdfd C |
6 | if (value.substring(0, 1) === '-') { |
7 | direction = 'DESC' | |
8 | field = value.substring(1) | |
9 | } else { | |
10 | direction = 'ASC' | |
11 | field = value | |
12 | } | |
5c39adb7 | 13 | |
feb4bdfd | 14 | return [ field, direction ] |
5c39adb7 C |
15 | } |
16 | ||
e02643f3 C |
17 | function addMethodsToModel (model: any, classMethods: Function[], instanceMethods: Function[] = []) { |
18 | classMethods.forEach(m => model[m.name] = m) | |
19 | instanceMethods.forEach(m => model.prototype[m.name] = m) | |
20 | } | |
21 | ||
5c39adb7 C |
22 | // --------------------------------------------------------------------------- |
23 | ||
65fcc311 | 24 | export { |
e02643f3 | 25 | addMethodsToModel, |
65fcc311 C |
26 | getSort |
27 | } |