uSmart Resource Query Language

Introduction

The **U**Smart **R**esource **Q**uery **L**anguage (URQL) allows you to search for specific records within an application programming interface (API) resource. We've based URQL loosely on

[RQL](https://github.com/persvr/rql ).

URQL Rules

The URQL grammar is based around standard URI delimiters. The standard rules for encoding strings with URL encoding (%xx) are observed. URQL also supersets FIQL. Therefore we can write a query that finds resources with a "price" property below 10 with a "lt" operator using FIQL syntax:

    price=lt=10

Which is identical (and sugar for call operator syntax known as the normalized form):

    lt(price,10)

One can combine conditions with multiple operators with "&":

    foo=3&price=lt=10

Is the same as:

    eq(foo,3)&lt(price,10)

Which is also the same as:

    and(eq(foo,3),lt(price,10))

The | operator can be used to indicate an "or" operation. We can also use paranthesis to group expressions. For example:

    (foo=3|foo=bar)&price=lt=10

Which is the same as:

    and(or(eq(foo,3),eq(foo,bar)),lt(price,10))

Values in queries can be strings (using URL encoding), numbers, booleans, null, undefined, and dates (in ISO UTC format without colon encoding). We can also denote arrays with paranthesis enclosed, comma separated values. For example to find the objects where foo can be the number 3, the string bar, the boolean true, or the date for the first day of the century we could write an array with the "in" operator:

    foo=in=(3,bar,true,2000-01-01T00:00:00Z)

We can also explicitly specify primitive types in queries. To explicitly specify a string "3",

we can do:

    foo=string:3 

Another common operator is sort. We can use the sort operator to sort by a specified property. To sort by foo in ascending order:

    price=lt=10&sort(+foo)

We can also do multiple property sorts. To sort by price in ascending order and rating in descending order:

    sort(+price,-rating)

Special Time Example

When writing time based queries you may have to ensure you follow these rules:

Query operators

As a guide where ‘property’ is mentioned this represents the column header on your data source or a key represented in the json provided through the API you have created on your dataset. ‘Value’ represents the properties value to be matched on for your query.

Filter query

These are queries that filter and can be chained together to return what you require from your data source:

Equals `eq(property,value)` -

The eq operator filters for objects where the specified property's value is equal to the provided value.

find WHERE ‘property’ is ‘value’ and return only those results.

In `in(property,(valueA,ValueB,…))`

The in operator works like eq however takes a value array denoted by the curly braces enclosing a comma separated list. It will return all results where any of the values is contained within the property specified.

Find WHERE ‘property’ IN (valueA, valueB, …);

Less than / Lower than ` lt(property,value) `

The lt operator filters for results where the specified property's value is less than the provided value.

Find where ‘property’ < ‘value’ and return those results.

Less than or Equal to `le(property,value,*interval,*start_of_interval) ` -

Less than or equal to will filter for results where the specified property's value is less than or equal to the provided value. The operator can also accept date math : (property,value,-1M,M)

Greater than `gt(property,value) `

Filters for results where the specified property's value is greater than the provided value.

Find where ‘property’ > ‘value’ and return those results.

Greater than or Equal to `ge(property,value,interval,start_of_interval) `

Greater than or equal to will filter for results where the specified property's value is greater than or equal to the provided value. The operator can also accept date math : (property,value,-1M,M)

Not equal to `ne(property,value)`

Not equal to filters for results where the specified property's value is not equal to the provided value

Find where ‘property’ is NOT equal to ‘value’ and return those results.

Freetext query

Freetext queries are used to match ‘keyword’ typings mainly, excluding the ‘Regex’ operator. You can find the typings of your column on the dataset page within page 3 of main info.

Regex Matcher `re(property,value) ` -

Filters for objects where the specified property's value is in the regular expression value

Aggregation query

Special Operations

Spatial query

 Combining queries

Sorting, selecting return values and paging

Cacheing

Cacheing can be used to help improve query return reliability and speed up the return of data from a dataset. This is done by adding the term cache=true

cache=true

. An example of that being used is shown below:

Others

 

Highlight important information in a panel like this one. To edit this panel's color or style, select one of the options in the menu below.

Related articles

The content by label feature displays related articles automatically, based on labels you choose. To edit options for this feature, select the placeholder below and tap the pencil icon.

Related issues