Querying records in a date range

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsQuerying records in a date range
(Created page with "### Tutorial Query a SQL or NoSQL database for records within a date range using a filter string. Try these examples in the 'API Docs' tab of the DreamFactory Admin Console o...")
Line 13: Line 13:
 
[[File:Swagger-date-filter.png|1000px]]
 
[[File:Swagger-date-filter.png|1000px]]
  
### Example - Query 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 - Query 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%20contacted_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%20contacted_date%20%3C%3D%202015-10-31</pre>

Revision as of 17:17, 15 October 2015

      1. Tutorial

Query a SQL or NoSQL database for records 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.

      1. API Endpoint
GET https://{url}/api/v2/{api_name}/_table/{table_name}?filter={filter_string}
      1. API Docs Screenshot

Swagger-date-filter.png

      1. 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
      1. 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%20contacted_date%20%3C%3D%202015-10-31