Fix sorting bug in API

This commit is contained in:
Zaid Abdulla committed 2016-01-13 18:14:21 +03:00
1 parent f99cf20580
commit 2aaec7bde5
1 file changed
+9 -2
+9 -2
View File
@@ -385,9 +385,16 @@ listener = (request, response) ->
sort = {}
for k,v of s
if aliases[k]?
sort[a] = v for a in aliases[k]
for a in aliases[k]
if a[a.lastIndexOf('.')+1] != '_' and collectionName is 'devices'
sort["#{a}._value"] = v
else
sort[a] = v
else
sort[k] = v
if k[k.lastIndexOf('.') + 1] != '_' and collectionName is 'devices'
sort["#{k}._value"] = v
else
sort[k] = v
cur.sort(sort)
cur.skip(parseInt(urlParts.query.skip)) if urlParts.query.skip?