Querying records with logical filters

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsQuerying records with logical filters
Line 22: Line 22:
  
 
* Table name: contact
 
* Table name: contact
* Filter parameter in API call: last_name = Yang
+
* Filter parameter in API call: <pre>last_name = Yang</pre>
* Request URL: https://your-url/api/v2/db/_table/contact?filter=last_name%20%3D%20Yang
+
* Request URL: <pre>https://your-url/api/v2/db/_table/contact?filter=last_name%20%3D%20Yang</pre>
  
 
### Example - Query contact records whose first name is 'Jon' and last name is 'Yang'
 
### Example - Query contact records whose first name is 'Jon' and last name is 'Yang'
  
 
* Table name: contact
 
* Table name: contact
* Filter parameter in API call: first_name = Jon and last_name = Yang
+
* Filter parameter in API call: <pre>first_name = Jon and last_name = Yang</pre>
* Request URL: https://your-url/api/v2/db/_table/contact?filter=first_name%20%3D%20Jon%20and%20last_name%20%3D%20Yang
+
* Request URL: <pre>https://your-url/api/v2/db/_table/contact?filter=first_name%20%3D%20Jon%20and%20last_name%20%3D%20Yang</pre>
  
 
### Example - Query contact records whose first name starts with 'J' and last name starts with 'Y'
 
### Example - Query contact records whose first name starts with 'J' and last name starts with 'Y'
  
 
* Table name: contact
 
* Table name: contact
* Filter parameter in API call: first_name like J% and last_name like Y%
+
* Filter parameter in API call: <pre>first_name like J% and last_name like Y%</pre>
* Request URL: https://your-url/api/v2/db/_table/contact?filter=first_name%20like%20J%25%20and%20last_name%20like%20Y%25
+
* Request URL: <pre>https://your-url/api/v2/db/_table/contact?filter=first_name%20like%20J%25%20and%20last_name%20like%20Y%25</pre>
  
 
### Example - Query contact records whose Twitter handle contains 'jon' or whose Skype handle contains 'jon'
 
### Example - Query contact records whose Twitter handle contains 'jon' or whose Skype handle contains 'jon'
  
 
* Table name: contact
 
* Table name: contact
* Filter parameter in API call: twitter like %jon% or skype like %jon%
+
* Filter parameter in API call: <pre>twitter like %jon% or skype like %jon%</pre>
* Request URL: https://your-url/api/v2/db/_table/contact?filter=twitter%20like%20%25jon%25%20or%20skype%20like%20%25jon%25
+
* Request URL: <pre>https://your-url/api/v2/db/_table/contact?filter=twitter%20like%20%25jon%25%20or%20skype%20like%20%25jon%25</pre>
  
 
### Supported SQL Databases
 
### Supported SQL Databases

Revision as of 02:03, 17 September 2015

      1. Tutorial

Query a SQL or NoSQL database by appending filter strings into a REST API call. 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 <, <=, >, >=, =, or, and, like.

      1. API Endpoint
GET https://your-url/api/v2/your-api-name/_table/{table_name}?filter=your-filter-string
      1. API Docs Screenshot

Swagger-filter.png

      1. Example - Fetch contact records whose last name starts with 'Y'
  • Table name: contact
  • Filter parameter in API call:
    last_name like Y%
  • Request URL:
    https://your-url/api/v2/db/_table/contact?filter=last_name%20like%20Y%25
      1. Example - Query contact records whose last name is 'Yang'
  • Table name: contact
  • Filter parameter in API call:
    last_name = Yang
  • Request URL:
    https://your-url/api/v2/db/_table/contact?filter=last_name%20%3D%20Yang
      1. Example - Query contact records whose first name is 'Jon' and last name is 'Yang'
  • Table name: contact
  • Filter parameter in API call:
    first_name = Jon and last_name = Yang
  • Request URL:
    https://your-url/api/v2/db/_table/contact?filter=first_name%20%3D%20Jon%20and%20last_name%20%3D%20Yang
      1. Example - Query contact records whose first name starts with 'J' and last name starts with 'Y'
  • Table name: contact
  • Filter parameter in API call:
    first_name like J% and last_name like Y%
  • Request URL:
    https://your-url/api/v2/db/_table/contact?filter=first_name%20like%20J%25%20and%20last_name%20like%20Y%25
      1. Example - Query contact records whose Twitter handle contains 'jon' or whose Skype handle contains 'jon'
  • Table name: contact
  • Filter parameter in API call:
    twitter like %jon% or skype like %jon%
  • Request URL:
    https://your-url/api/v2/db/_table/contact?filter=twitter%20like%20%25jon%25%20or%20skype%20like%20%25jon%25
      1. Supported SQL Databases
  • PostgreSQL
  • MySQL
  • SQLite
  • SQLite 2
  • MS SQL Server
  • Sybase
  • Oracle
  • IBM DB2
      1. Supported NoSQL Databases
  • MongoDB
  • CouchDB
  • DynamoDB
  • Azure Tables