The main model to query a collection of entities is Filter, and it is parametrized in the type CustomModel that represents the type of the entities to query.
All filters are optional and must be specified as a query string parameter named filter in JSON format.
For some entities, there could be filter constructions that does not work for technical limitations, such as storage engine.
Query filter object.
| Field | Type | Description |
|---|---|---|
where |
Where<CustomModel> | [Optional] The matching criteria. |
fields |
Fields<CustomModel> | [Optional] To include/exclude fields. |
order |
string[] | [Optional] Sorting order for matched entities. Each item should be formatted as fieldName ASC or fieldName DESC. For example: ['f1 ASC', 'f2 DESC', 'f3 ASC']. |
limit |
number | [Optional] Maximum number of entities. |
skip |
number | [Optional] Skip N number of entities. |
offset |
number | [Optional] Offset N number of entities. An alias for skip. |
include |
Inclusion[] | [Optional] To include related objects. |
Where clause to specify the selection condition.
Examples:
{
name: { inq: ['John', 'Mary'] },
status: 'ACTIVE'
}
{
and: [{ status: 'ACTIVE' }, ...]
}
{
or: [{ status: 'ACTIVE' }, ...]
}
The values of Where<CustomModel> type must be any of:
Condition to filter entities.
Example:
{
name: { inq: ['John', 'Mary'] },
status: 'ACTIVE',
age: { gte: 40 }
}
| Field | Type | Description |
|---|---|---|
[P in keyof CustomModel] |
One of: - PredicateComparison<CustomModel[P]> - ShortPredicate<CustomModel[P]> |
[Optional] P is any of the fields in CustomModel. Represents a condition where the field P is involved. |
Matching predicate comparison.
It is parametrized in a property type PType.
| Field | Type | Description |
|---|---|---|
eq |
PType | [Optional] Equivalence (==). |
neq |
PType | [Optional] Not equal (!=). |
gt |
PType | [Optional] Greater than (>). |
gte |
PType | [Optional] Greater than or equal (>=). |
lt |
PType | [Optional] Less than (<). |
lte |
PType | [Optional] Less than or equal (<=). |
inq |
PType[] | [Optional] Include operator. True only if the value is one of the included in a specified array of values. |
nin |
PType[] | [Optional] Not include operator. True only if the value is not one of the included in a specified array of values. |
between |
[PType, PType] | [Optional] Between operator. True only if the value is between the two specified values: greater than or equal to first value and less than or equal to second value. The min and max values are specified in an array of two elements. |
exists |
boolean | [Optional] To check if a property exists or not. |
like |
PType | [Optional] Like operator to match using a database regular expression with case sensitive. |
nlike |
PType | [Optional] Not like operator to match values that does not follow a database regular expression, with case sensitive. |
ilike |
PType | [Optional] Like operator to match using a database regular expression with case insensitive. |
nilike |
PType | [Optional] Not like operator to match values that does not follow a database regular expression, with case insensitive. |
regexp |
string | [Optional] Match values using a standard regular expression. |
Shortcut of a PredicateComparison<PType> with the property eq for equivalence.
The value must be of the type of the property being filtered (PType).
Only available for properties of the type string, number or boolean.
And clause.
Example:
{ and: [...] }
| Field | Type | Description |
|---|---|---|
and |
Where<CustomModel>[] | Array of conditions. |
Or clause.
Example:
{ or: [...] }
| Field | Type | Description |
|---|---|---|
or |
Where<CustomModel>[] | Array of conditions. |
Selection of fields.
Example: {aFieldName: true, anotherFieldName: true}.
| Field | Type | Description |
|---|---|---|
[P in keyof CustomModel] |
boolean | [Optional] P is any of the fields in CustomModel. When it is set to true, the field is included in the result. When false or omitted, the field is not included. |
Inclusion of related items.
Note: scope means filter on related items.
Example: {relation: 'aRelationName', scope: {<AFilterObject>}}.
| Field | Type | Description |
|---|---|---|
relation |
string | Name of the relation. |
scope |
Filter<RelatedModel> | [Optional] Filter for the related model. |