Sorting records

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsSorting records
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
### Tutorial
 
 
 
Sort records in a SQL or NoSQL GET request. Try these examples in the 'API Docs' tab of the DreamFactory Admin Console or from the command line with cURL.
 
Sort records in a SQL or NoSQL GET request. Try these examples in the 'API Docs' tab of the DreamFactory Admin Console or from the command line with cURL.
  
### API Endpoint
+
=== API Endpoint ===
  
 
<pre>GET https://{url}/api/v2/{api_name}/_table/{table_name}?order={sort_order}</pre>
 
<pre>GET https://{url}/api/v2/{api_name}/_table/{table_name}?order={sort_order}</pre>
  
### API Docs Screenshot
+
=== API Docs Screenshot ===
  
 
[[File:Swagger-order.png|1000px]]
 
[[File:Swagger-order.png|1000px]]
  
### Example - GET contact records and sort by last name ascending  
+
=== Example - GET contact records and sort by last name ascending ===
  
 
* Table name: contact
 
* Table name: contact
Line 17: Line 15:
 
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact?order=last_name%20ASC</pre>
 
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact?order=last_name%20ASC</pre>
  
### Example - GET contact records and sort by last name descending
+
=== Example - GET contact records and sort by last name descending ===
  
 
* Table name: contact
 
* Table name: contact
Line 23: Line 21:
 
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact?order=last_name%20DESC</pre>
 
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact?order=last_name%20DESC</pre>
  
### Example - GET contact records and sort by last name ascending, then by first name ascending (nested sort)
+
=== Example - GET contact records and sort by last name ascending, then by first name ascending (nested sort) ===
  
 
* Table name: contact
 
* Table name: contact
 
* Order parameter in API call: <pre>last_name ASC, first_name ASC</pre>
 
* Order parameter in API call: <pre>last_name ASC, first_name ASC</pre>
 
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact?order=last_name%20ASC%2C%20first_name%20ASC</pre>
 
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact?order=last_name%20ASC%2C%20first_name%20ASC</pre>

Latest revision as of 20:12, 22 June 2016

Sort records in a SQL or NoSQL GET request. Try these examples in the 'API Docs' tab of the DreamFactory Admin Console or from the command line with cURL.

API Endpoint

GET https://{url}/api/v2/{api_name}/_table/{table_name}?order={sort_order}

API Docs Screenshot

Swagger-order.png

Example - GET contact records and sort by last name ascending

  • Table name: contact
  • Order parameter in API call:
    last_name ASC
  • Request URL:
    https://foo.com/api/v2/db/_table/contact?order=last_name%20ASC

Example - GET contact records and sort by last name descending

  • Table name: contact
  • Order parameter in API call:
    last_name DESC
  • Request URL:
    https://foo.com/api/v2/db/_table/contact?order=last_name%20DESC

Example - GET contact records and sort by last name ascending, then by first name ascending (nested sort)

  • Table name: contact
  • Order parameter in API call:
    last_name ASC, first_name ASC
  • Request URL:
    https://foo.com/api/v2/db/_table/contact?order=last_name%20ASC%2C%20first_name%20ASC