Skip to content

Instantly share code, notes, and snippets.

@PericlesTheo
Created January 14, 2022 09:08
Show Gist options
  • Save PericlesTheo/534c2ed18c7ca2ed3e63672c1c3c64df to your computer and use it in GitHub Desktop.
Save PericlesTheo/534c2ed18c7ca2ed3e63672c1c3c64df to your computer and use it in GitHub Desktop.
Definition of query language
type Query = {
search?: string,
filter_group: FilterGroup,
pagination: Pagination,
sort: Sort
}
type FilterGroup = {
conditional: Conditional,
expressions: Array<Filter | FilterGroup>
}
enum Conditional {
And = "and",
Or = "or"
}
type Filter = {
property: string,
operator: Operator,
values: Array<string | number | boolean>
}
enum Operator {
Eq = "equal",
NotEq = "not_equal",
Lte = "lte",
Lt = "lt" ,
Gt = "gt",
Gte = "gte",
Exist = "exist",
NotExist = "not_exist",
In = "in",
NotIn = "not_in"
}
type Sort = {
property: string,
direction: Direction
}
enum Direction {
Asc = "asc",
Desc = "desc"
}
type Pagination = {
page: number,
perPage: number
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment