Skip to content
Snippets Groups Projects
Commit c8c54f9a authored by Nico Vermaas's avatar Nico Vermaas
Browse files

add sort direction

parent b959923c
No related branches found
No related tags found
1 merge request!2add sort direction
......@@ -136,8 +136,14 @@ class DataProductDB:
# if a &sort=<field> url parameter is given then use sort, otherwise omit it (backward compatibility)
if sort:
if sort[0]=='-':
direction = -1
sort = sort[1:]
else:
direction = 1
results = [augment_item(item) for item in
self.db[collection_name].find(query, selected_fields).skip(skip).limit(limit).sort(sort)]
self.db[collection_name].find(query, selected_fields).skip(skip).limit(limit).sort(sort,direction)]
else:
results = [augment_item(item) for item in
self.db[collection_name].find(query, selected_fields).skip(skip).limit(limit)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment