From 65fcc3119c334b75dd13bcfdebf186afdc580a8f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 15 May 2017 22:22:03 +0200 Subject: First typescript iteration --- server/models/utils.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 server/models/utils.ts (limited to 'server/models/utils.ts') diff --git a/server/models/utils.ts b/server/models/utils.ts new file mode 100644 index 000000000..601811913 --- /dev/null +++ b/server/models/utils.ts @@ -0,0 +1,21 @@ +// Translate for example "-name" to [ 'name', 'DESC' ] +function getSort (value) { + let field + let direction + + if (value.substring(0, 1) === '-') { + direction = 'DESC' + field = value.substring(1) + } else { + direction = 'ASC' + field = value + } + + return [ field, direction ] +} + +// --------------------------------------------------------------------------- + +export { + getSort +} -- cgit v1.2.3