Skip to content

Commit dbc6b56

Browse files
another fix for order_by
1 parent 3ad3ac2 commit dbc6b56

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/woql.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,19 @@ WOQLQuery.prototype.file = function(json, opts){
711711
}
712712

713713
WOQLQuery.prototype.order_by = function(asc_or_desc, query){
714-
asc_or_desc = (asc_or_desc.json ? asc_or_desc.json() : asc_or_desc);
715-
this.cursor["order_by"] = [asc_or_desc]
714+
let ovars = [];
715+
if(Array.isArrray(asc_or_desc)){
716+
for(var i = 0; i<asc_or_desc.length; i++){
717+
ovars.push(asc_or_desc[i].json ? asc_or_desc[i].json() : asc_or_desc[i])
718+
}
719+
}
720+
else if(typeof asc_or_desc == "string"){
721+
ovars.push({"asc": [asc_or_desc]});
722+
}
723+
else {
724+
ovars.push(asc_or_desc.json ? asc_or_desc.json() : asc_or_desc)
725+
}
726+
this.cursor["order_by"] = [ovars]
716727
if(query){
717728
this.cursor["order_by"] .push(query.json ? query.json() : query);
718729
}

0 commit comments

Comments
 (0)