Skip to content

Commit

Permalink
sort applied do read and empty sort check added #14
Browse files Browse the repository at this point in the history
  • Loading branch information
serayuzgur committed May 10, 2017
1 parent e35c828 commit 4955152
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/database/query_api/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ fn compare(a: &Map<String, Value>, b: &Map<String, Value>, sort_key: &String) ->

/// sort on all desired fields fields according to the query api
pub fn apply(obj: &mut Value, queries: &Queries) {
if queries.sort.len() == 0 {
return;
}
if let &mut Value::Array(ref mut arr) = obj {
let ref sorts = queries.sort;
arr.sort_by(|a: &Value, b: &Value| {
Expand Down
1 change: 1 addition & 0 deletions src/database/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ impl Database {
let clone = &mut obj.clone();
query_api::filter::apply(clone, &q);
query_api::q::apply(clone, &q);
query_api::sort::apply(clone, &q);
return Ok(clone.clone());
}
return Ok(obj.clone());
Expand Down

0 comments on commit 4955152

Please sign in to comment.