Creatio. OData. Query
(creatio v0.3.1)
Copy Markdown
Composable query builder for Creatio OData 4 requests.
Supports $select, $filter, $orderby, $top, $skip, $expand, and $count.
Provides chainable filter helpers for standard OData functions and operators
(eq, ne, gt, ge, lt, le, contains, startswith, endswith, day, length, not, in).
Examples
query =
Creatio.OData.Query.new("Contact")
|> Creatio.OData.Query.select(["Id", "Name", "Email"])
|> Creatio.OData.Query.filter_eq("Active", true)
|> Creatio.OData.Query.filter_contains("Name", "Smith")
|> Creatio.OData.Query.order_by("Name asc")
|> Creatio.OData.Query.top(25)
|> Creatio.OData.Query.skip(50)
|> Creatio.OData.Query.expand("Account")
|> Creatio.OData.Query.count()
{:ok, records} = Creatio.OData.execute(client, query)
Summary
Functions
Combines an additional filter expression with and.
Toggles whether to request total inline count ($count=true).
Specifies navigation properties to expand ($expand).
Can be called multiple times to accumulate properties.
Specifies or replaces the filter expression ($filter).
Adds an OData 4 string contains condition (contains({field}, '{value}')).
Adds an OData day date function condition (day({field}) {op} {value}).
Adds an OData string endswith condition (endswith({field}, '{value}')).
Adds an equality condition ({field} eq {value}).
Literals (numbers, booleans, null) are formatted automatically without quotes.
Pass quoted: false for unquoted GUIDs / IDs.
Adds a greater-than-or-equal condition ({field} ge {value}).
Adds a greater-than condition ({field} gt {value}).
Adds a GUID equality condition ({field} eq {guid}).
In OData 4, GUIDs are unquoted literals.
In OData 3 (pass protocol: :odata3 or odata3: true), GUIDs are formatted as guid'{guid}'.
Builds an OData filter condition checking if a field equals any of a list of values.
Since Creatio OData 4 does not support the in operator, this constructs
(Field eq 'v1' or Field eq 'v2').
Builds an OData filter condition for a list of UUID / GUID primary keys.
Since GUIDs in OData 4 are unquoted literals, this formats as (Id eq uuid1 or Id eq uuid2).
Adds a less-than-or-equal condition ({field} le {value}).
Adds an OData length string function condition (length({field}) {op} {value}).
Adds a less-than condition ({field} lt {value}).
Adds an inequality condition ({field} ne {value}).
Negates the current filter (not ({current})) or an explicitly provided expression.
Adds an OData string startswith condition (startswith({field}, '{value}')).
Initializes a new query for an entity collection.
Combines an additional filter expression with or.
Adds an OData 4 string contains condition combined with or.
Adds an OData day date function condition combined with or (day({field}) {op} {value}).
Adds an OData string endswith condition combined with or.
Adds an equality condition combined with or ({field} eq {value}).
Adds a greater-than-or-equal condition combined with or ({field} ge {value}).
Adds a greater-than condition combined with or ({field} gt {value}).
Adds a GUID equality condition combined with or ({field} eq {guid}).
Builds an OData filter condition checking if a field equals any of a list of values, combined with or.
Adds a less-than-or-equal condition combined with or ({field} le {value}).
Adds an OData length string function condition combined with or (length({field}) {op} {value}).
Adds a less-than-or-equal condition combined with or ({field} lt {value}).
Adds an inequality condition combined with or ({field} ne {value}).
Adds an OData string startswith condition combined with or.
Combines an additional filter expression with or. Alias for or_filter/2.
Specifies the ordering clause ($orderby).
Accepts a string, atom, keyword list (e.g. [Name: :asc, CreatedOn: :desc]), or list of strings.
Can be called multiple times to append ordering clauses.
Specifies the ordering clause with a field and direction (e.g. order_by(query, :Name, :asc)).
Adds an arbitrary custom query parameter.
Specifies the fields to retrieve ($select).
Can be called multiple times to accumulate fields.
Specifies number of records to skip ($skip).
Serializes the query into a map of query parameters ready for the HTTP request.
Returns the URL query string representation for the query.
Specifies maximum records to return ($top).
Combines an additional filter expression with and. Alias for and_filter/2.
Types
Functions
Combines an additional filter expression with and.
Toggles whether to request total inline count ($count=true).
Specifies navigation properties to expand ($expand).
Can be called multiple times to accumulate properties.
Specifies or replaces the filter expression ($filter).
Adds an OData 4 string contains condition (contains({field}, '{value}')).
Adds an OData day date function condition (day({field}) {op} {value}).
Adds an OData string endswith condition (endswith({field}, '{value}')).
Adds an equality condition ({field} eq {value}).
Literals (numbers, booleans, null) are formatted automatically without quotes.
Pass quoted: false for unquoted GUIDs / IDs.
Adds a greater-than-or-equal condition ({field} ge {value}).
Adds a greater-than condition ({field} gt {value}).
Adds a GUID equality condition ({field} eq {guid}).
In OData 4, GUIDs are unquoted literals.
In OData 3 (pass protocol: :odata3 or odata3: true), GUIDs are formatted as guid'{guid}'.
Builds an OData filter condition checking if a field equals any of a list of values.
Since Creatio OData 4 does not support the in operator, this constructs
(Field eq 'v1' or Field eq 'v2').
Options
:quoted- boolean indicating whether to wrap values in single quotes (defaulttrue).
Builds an OData filter condition for a list of UUID / GUID primary keys.
Since GUIDs in OData 4 are unquoted literals, this formats as (Id eq uuid1 or Id eq uuid2).
Adds a less-than-or-equal condition ({field} le {value}).
Adds an OData length string function condition (length({field}) {op} {value}).
Adds a less-than condition ({field} lt {value}).
Adds an inequality condition ({field} ne {value}).
Negates the current filter (not ({current})) or an explicitly provided expression.
Adds an OData string startswith condition (startswith({field}, '{value}')).
Initializes a new query for an entity collection.
Combines an additional filter expression with or.
Adds an OData 4 string contains condition combined with or.
Adds an OData day date function condition combined with or (day({field}) {op} {value}).
Adds an OData string endswith condition combined with or.
Adds an equality condition combined with or ({field} eq {value}).
Adds a greater-than-or-equal condition combined with or ({field} ge {value}).
Adds a greater-than condition combined with or ({field} gt {value}).
Adds a GUID equality condition combined with or ({field} eq {guid}).
Builds an OData filter condition checking if a field equals any of a list of values, combined with or.
Adds a less-than-or-equal condition combined with or ({field} le {value}).
Adds an OData length string function condition combined with or (length({field}) {op} {value}).
Adds a less-than-or-equal condition combined with or ({field} lt {value}).
Adds an inequality condition combined with or ({field} ne {value}).
Adds an OData string startswith condition combined with or.
Combines an additional filter expression with or. Alias for or_filter/2.
Specifies the ordering clause ($orderby).
Accepts a string, atom, keyword list (e.g. [Name: :asc, CreatedOn: :desc]), or list of strings.
Can be called multiple times to append ordering clauses.
Specifies the ordering clause with a field and direction (e.g. order_by(query, :Name, :asc)).
Adds an arbitrary custom query parameter.
Specifies the fields to retrieve ($select).
Can be called multiple times to accumulate fields.
@spec skip(t(), non_neg_integer()) :: t()
Specifies number of records to skip ($skip).
Serializes the query into a map of query parameters ready for the HTTP request.
Returns the URL query string representation for the query.
@spec top(t(), non_neg_integer()) :: t()
Specifies maximum records to return ($top).
Combines an additional filter expression with and. Alias for and_filter/2.
Alias for filter_eq/4.