Querying records in a date range

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsQuerying records in a date range
Line 1: Line 1:
### Tutorial
+
=== Tutorial ===
  
 
GET records in a SQL or NoSQL database within a date range using a filter string. Try these examples in the 'API Docs' tab of the DreamFactory Admin Console or from the command line with cURL.
 
GET records in a SQL or NoSQL database within a date range using a filter string. Try these examples in the 'API Docs' tab of the DreamFactory Admin Console or from the command line with cURL.
Line 5: Line 5:
 
Note that filter strings are simply SQL queries with ordinary SQL operators, including <, <=, >, >=, =, etc.
 
Note that filter strings are simply SQL queries with ordinary SQL operators, including <, <=, >, >=, =, etc.
  
### API Endpoint
+
=== API Endpoint ===
  
 
<pre>GET https://{url}/api/v2/{api_name}/_table/{table_name}?filter={filter_string}</pre>
 
<pre>GET https://{url}/api/v2/{api_name}/_table/{table_name}?filter={filter_string}</pre>
  
### API Docs Screenshot
+
=== API Docs Screenshot ===
  
 
[[File:Swagger-date-filter.png|1000px]]
 
[[File:Swagger-date-filter.png|1000px]]
  
### Example - GET contact records with contacted_date equal to October 1, 2015
+
=== Example - GET contact records with contacted_date equal to October 1, 2015 ===
  
 
* Table name: contact
 
* Table name: contact
Line 19: Line 19:
 
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact?filter=contacted_date%20%3D%202015-10-01</pre>
 
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact?filter=contacted_date%20%3D%202015-10-01</pre>
  
### Example - GET contact records with contacted_date in the month of October, 2015
+
=== Example - GET contact records with contacted_date in the month of October, 2015 ===
  
 
* Table name: contact
 
* Table name: contact
 
* Filter parameter in API call: <pre>(contacted_date >= 2015-10-01) AND (contacted_date <= 2015-10-31)</pre>
 
* Filter parameter in API call: <pre>(contacted_date >= 2015-10-01) AND (contacted_date <= 2015-10-31)</pre>
 
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact?filter=(contacted_date%20%3E%3D%202015-10-01)%20AND%20(contacted_date%20%3C%3D%202015-10-31)</pre>
 
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact?filter=(contacted_date%20%3E%3D%202015-10-01)%20AND%20(contacted_date%20%3C%3D%202015-10-31)</pre>

Revision as of 17:46, 3 February 2016

Tutorial

GET records in a SQL or NoSQL database within a date range using a filter string. Try these examples in the 'API Docs' tab of the DreamFactory Admin Console or from the command line with cURL.

Note that filter strings are simply SQL queries with ordinary SQL operators, including <, <=, >, >=, =, etc.

API Endpoint

GET https://{url}/api/v2/{api_name}/_table/{table_name}?filter={filter_string}

API Docs Screenshot

Swagger-date-filter.png

Example - GET contact records with contacted_date equal to October 1, 2015

  • Table name: contact
  • Filter parameter in API call:
    contacted_date = 2015-10-01
  • Request URL:
    https://foo.com/api/v2/db/_table/contact?filter=contacted_date%20%3D%202015-10-01

Example - GET contact records with contacted_date in the month of October, 2015

  • Table name: contact
  • Filter parameter in API call:
    (contacted_date >= 2015-10-01) AND (contacted_date <= 2015-10-31)
  • Request URL:
    https://foo.com/api/v2/db/_table/contact?filter=(contacted_date%20%3E%3D%202015-10-01)%20AND%20(contacted_date%20%3C%3D%202015-10-31)