Aviato DSL V1
About
The Aviato DSL is a custom query language inspired by Elasticsearch based on JSON that allows the usage of complex filters easily.
DSL Structure
All the following attributes are placed at the top level of the DSL. All fields are required unless otherwise stated
Filter Object
Only one of the following fields can be used per filter object
Column Paths
This can reference three things: scalar fields, relational fields, and function calls
Scalar Fields: These are simple scalar fields that exist on the table being queried specified in the “collections” attribute. They must exist as a scalar field in the Prisma schema
Relational Fields: These are relational fields, with no cap on the amount of relations. Each relation is separated by dot notation. The last specified column must be a scalar column. You do NOT navigate by specifying the model name, but instead by the “virtual column name.” Ex: If you’re querying the Person table, and want to filter on the WorkExperienceLink table, the constructed column path would be workExperienceList.startDate
and NOT WorkExperienceList.startDate
. For example, to filter for companies with a specific founder, use companyFoundingLink.person.id
Function Calls: You can call custom pre-approved functions with inputs by simply calling the function like normal. Ex you would pass vesting_to_total_vested()
. To pass custom arguments in, simply pass them in as how you would speciffy scalar/relational fields: vesting_to_total_vested(experienceList.startDate, experienceList.company.vestingScheduleList[1]['schedule'])
-
Note that you can only use non-aggregate functions in filters. However, you can use aggregate functions in sort. Valid function calls include:
JSON Queries: You might find yourself wanting to query a JSON column’s subattributes. You can’t use dots (otherwise the DSL parser will think you’re trying to make a relational query). Instead, use square brackets. This can be used in tandem with the dots for scalar fields. Ex: experienceList.company.vestingScheduleList[1]['schedule']
. Single quotes are used for JSON sub attribute names, numbers without quotes are used for specifying a specific index in a JSON array.
Evaluation Object
- The
eq
noteq
lt
lte
gt
andgte
fields supportstrings
,numbers
, andDates
- The
fts
field supportsstrings
and does full text filtering (not ranking) - The
in
notin
fields supportarrays
ofnumbers
orstrings
- The
geowithin
field supportsarrays
ofstring
and does a filter on the specified bounding box. This only supports certain coordinate type fields:["(latitude, longitude)", "(latitude, longitude)"]
Where the first set of coordinates is the upper left coordinate of the bounding box, and the second set of coordinates is the lower right coordinate.- Ex
["(38.532667, -123.237130)", "(37.019316, -120.397669)"]
- Ex
- The
textcontains
field supports only strings.
Sort Object Example
The sort attribute also supports all column paths that the filters attribute supports. This includes sorting by relations, sorting by functions, including aggregate functions like COUNT()