Skip to content

UrbanTide/URQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

URQL

USMART Resource Query Language

Introduction

The USMART Resource Query Language (URQL) allows you to search for specific records within an API resource. We've based URQL loosely on 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)

Query operators

Filter query

Freetext query

Aggregation query

Special Operations

Spatial query

  • withinBoundingBox(geometryProperty,(minX,maxX,minY,maxY)) - Filters for objects where the specified geometry property's coordinates fall completely within the bounding box as defined by minimum and maximum X and Y values

Combining queries

  • and(query,query,...) - Applies all the given queries
  • or(query,query,...) - The union of the given queries

Sorting, selecting return values and paging

Others

  • format(ouputFormat) - Sets the output format - valid values are 'json' (default) and 'csv' (comma separated text file).
  • cache=true - Turn on cache option for this query

More Examples

TODO

About

USMART Resource Query Language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •