Class: default
data/Criteria.default
Constructors
constructor
• new default(page?
, limit?
)
Parameters
Name | Type | Default value |
---|---|---|
page | null | number | defaultPage |
limit | null | number | defaultLimit |
Defined in
packages/admin-sdk/src/data/Criteria.ts:202
Properties
page
• page: null
| number
Defined in
packages/admin-sdk/src/data/Criteria.ts:172
limit
• limit: null
| number
Defined in
packages/admin-sdk/src/data/Criteria.ts:174
term
• term: null
| string
Defined in
packages/admin-sdk/src/data/Criteria.ts:176
filters
• filters: SingleFilter
[]
Defined in
packages/admin-sdk/src/data/Criteria.ts:178
ids
• ids: string
[]
Defined in
packages/admin-sdk/src/data/Criteria.ts:180
queries
• queries: Query
[]
Defined in
packages/admin-sdk/src/data/Criteria.ts:182
associations
• associations: Association
[]
Defined in
packages/admin-sdk/src/data/Criteria.ts:184
postFilter
• postFilter: SingleFilter
[]
Defined in
packages/admin-sdk/src/data/Criteria.ts:186
sortings
• sortings: Sorting
[]
Defined in
packages/admin-sdk/src/data/Criteria.ts:188
aggregations
• aggregations: Aggregation
[]
Defined in
packages/admin-sdk/src/data/Criteria.ts:190
grouping
• grouping: string
[]
Defined in
packages/admin-sdk/src/data/Criteria.ts:192
fields
• fields: string
[]
Defined in
packages/admin-sdk/src/data/Criteria.ts:194
groupFields
• groupFields: string
[]
Defined in
packages/admin-sdk/src/data/Criteria.ts:196
totalCountMode
• totalCountMode: null
| TotalCountMode
Defined in
packages/admin-sdk/src/data/Criteria.ts:198
includes
• includes: null
| Include
Defined in
packages/admin-sdk/src/data/Criteria.ts:200
Methods
parse
▸ parse(): RequestParams
Parses the current criteria and generates an object which can be provided to the api
Returns
RequestParams
Defined in
packages/admin-sdk/src/data/Criteria.ts:227
setIds
▸ setIds(ids
): default
Allows to provide a list of ids which are used as a filter
Parameters
Name | Type |
---|---|
ids | string [] |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:288
setTotalCountMode
▸ setTotalCountMode(mode
): default
Allows to configure the total value of a search result. 0 - no total count will be selected. Should be used if no pagination required (fastest) 1 - exact total count will be selected. Should be used if an exact pagination is required (slow) 2 - fetches limit * 5 + 1. Should be used if pagination can work with "next page exists" (fast)
Parameters
Name | Type |
---|---|
mode | TotalCountMode |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:299
setPage
▸ setPage(page
): default
Parameters
Name | Type |
---|---|
page | number |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:308
setLimit
▸ setLimit(limit
): default
Parameters
Name | Type |
---|---|
limit | number |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:313
setTerm
▸ setTerm(term
): default
Parameters
Name | Type |
---|---|
term | string |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:318
addFilter
▸ addFilter(filter
): default
Parameters
Name | Type |
---|---|
filter | SingleFilter |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:323
addIncludes
▸ addIncludes(include
): default
Parameters
Name | Type |
---|---|
include | Include |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:329
addPostFilter
▸ addPostFilter(filter
): default
Adds the provided filter as post filter. Post filter will be considered for the documents query but not for the aggregations.
Parameters
Name | Type |
---|---|
filter | SingleFilter |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:348
addSorting
▸ addSorting(sorting
): default
Allows to add different sortings for the criteria, to sort the entity result.
Parameters
Name | Type |
---|---|
sorting | Sorting |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:356
addQuery
▸ addQuery(filter
, score
, scoreField?
): default
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Query\ScoreQuery. These queries are used to search for documents and score them with a ranking
Parameters
Name | Type | Default value |
---|---|---|
filter | SingleFilter | undefined |
score | number | undefined |
scoreField | null | string | null |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:365
addGroupField
▸ addGroupField(groupField
): default
Parameters
Name | Type |
---|---|
groupField | string |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:380
addGrouping
▸ addGrouping(field
): default
Allows grouping the result by a specific field
Parameters
Name | Type |
---|---|
field | string |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:388
addFields
▸ addFields(...field
): default
Allows loading partial fields for the result.
Parameters
Name | Type |
---|---|
...field | string [] |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:397
addAggregation
▸ addAggregation(aggregation
): default
Parameters
Name | Type |
---|---|
aggregation | Aggregation |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:406
addAssociation
▸ addAssociation(path
): default
Ensures that a criterion is created for each segment of the passed path. Existing Criteria objects are not overwritten. Returns the own instance
Parameters
Name | Type |
---|---|
path | string |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:416
getAssociation
▸ getAssociation(path
): default
Ensures that a criterion is created for each segment of the passed path. Returns the criteria instance of the last path segment
Parameters
Name | Type |
---|---|
path | string |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:433
getAssociationCriteria
▸ getAssociationCriteria(part
): null
| default
Parameters
Name | Type |
---|---|
part | string |
Returns
null
| default
Defined in
packages/admin-sdk/src/data/Criteria.ts:453
getLimit
▸ getLimit(): number
Returns
number
Defined in
packages/admin-sdk/src/data/Criteria.ts:465
getPage
▸ getPage(): number
Returns
number
Defined in
packages/admin-sdk/src/data/Criteria.ts:469
getCriteriaData
▸ getCriteriaData(): Object
Returns
Object
Name | Type |
---|---|
page | null | number |
limit | null | number |
term | null | string |
filters | SingleFilter [] |
ids | string [] |
queries | Query [] |
associations | Association [] |
postFilter | SingleFilter [] |
sortings | Sorting [] |
aggregations | Aggregation [] |
grouping | string [] |
fields | string [] |
groupFields | string [] |
totalCountMode | null | TotalCountMode |
includes | null | Include |
Defined in
packages/admin-sdk/src/data/Criteria.ts:473
hasAssociation
▸ hasAssociation(property
): boolean
Parameters
Name | Type |
---|---|
property | string |
Returns
boolean
Defined in
packages/admin-sdk/src/data/Criteria.ts:509
resetSorting
▸ resetSorting(): void
Resets the sorting parameter
Returns
void
Defined in
packages/admin-sdk/src/data/Criteria.ts:518
fromCriteria
▸ Static
fromCriteria(criteria
): default
Parameters
Name | Type |
---|---|
criteria | default |
Returns
Defined in
packages/admin-sdk/src/data/Criteria.ts:220
avg
▸ Static
avg(name
, field
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Metric\AvgAggregation Allows to calculate the avg value for the provided field
Parameters
Name | Type |
---|---|
name | string |
field | string |
Returns
Object
Name | Type |
---|---|
type | "avg" |
name | string |
field | string |
Defined in
packages/admin-sdk/src/data/Criteria.ts:526
count
▸ Static
count(name
, field
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Metric\CountAggregation Allows to calculate the count value for the provided field
Parameters
Name | Type |
---|---|
name | string |
field | string |
Returns
Object
Name | Type |
---|---|
type | "count" |
name | string |
field | string |
Defined in
packages/admin-sdk/src/data/Criteria.ts:534
max
▸ Static
max(name
, field
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Metric\MaxAggregation Allows to calculate the max value for the provided field
Parameters
Name | Type |
---|---|
name | string |
field | string |
Returns
Object
Name | Type |
---|---|
type | "max" |
name | string |
field | string |
Defined in
packages/admin-sdk/src/data/Criteria.ts:542
min
▸ Static
min(name
, field
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Metric\MinAggregation Allows to calculate the min value for the provided field
Parameters
Name | Type |
---|---|
name | string |
field | string |
Returns
Object
Name | Type |
---|---|
type | "min" |
name | string |
field | string |
Defined in
packages/admin-sdk/src/data/Criteria.ts:550
stats
▸ Static
stats(name
, field
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Metric\StatsAggregation Allows to calculate the sum, max, min, avg, count values for the provided field
Parameters
Name | Type |
---|---|
name | string |
field | string |
Returns
Object
Name | Type |
---|---|
type | "stats" |
name | string |
field | string |
Defined in
packages/admin-sdk/src/data/Criteria.ts:558
sum
▸ Static
sum(name
, field
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Metric\SumAggregation Allows to calculate the sum value for the provided field
Parameters
Name | Type |
---|---|
name | string |
field | string |
Returns
Object
Name | Type |
---|---|
type | "sum" |
name | string |
field | string |
Defined in
packages/admin-sdk/src/data/Criteria.ts:566
terms
▸ Static
terms(name
, field
, limit?
, sort?
, aggregation?
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Bucket\TermsAggregation Allows to fetch term buckets for the provided field
Parameters
Name | Type | Default value |
---|---|---|
name | string | undefined |
field | string | undefined |
limit | null | number | null |
sort | null | Sorting | null |
aggregation | null | Aggregation | null |
Returns
Object
Name | Type |
---|---|
type | "terms" |
name | string |
field | string |
limit | null | number |
sort | null | Sorting |
aggregation | null | Aggregation |
Defined in
packages/admin-sdk/src/data/Criteria.ts:574
filter
▸ Static
filter(name
, filter
, aggregation
): Filter
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Bucket\FilterAggregation Allows to filter an aggregation result
Parameters
Name | Type |
---|---|
name | string |
filter | SingleFilter [] |
aggregation | Aggregation [] |
Returns
Filter
Defined in
packages/admin-sdk/src/data/Criteria.ts:588
histogram
▸ Static
histogram(name
, field
, interval
, format
, aggregation
, timeZone
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Bucket\DateHistogramAggregation Allows to fetch date buckets for the provided date interval
Parameters
Name | Type |
---|---|
name | string |
field | string |
interval | null | string |
format | null | string |
aggregation | null | Aggregation |
timeZone | null | string |
Returns
Object
Name | Type |
---|---|
type | "histogram" |
name | string |
field | string |
interval | null | string |
format | null | string |
aggregation | null | Aggregation |
timeZone | null | string |
Defined in
packages/admin-sdk/src/data/Criteria.ts:596
sort
▸ Static
sort(field
, order?
, naturalSorting?
): Sorting
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting. Allows to sort the documents by the provided field
Parameters
Name | Type | Default value |
---|---|---|
field | string | undefined |
order | "ASC" | "DESC" | 'ASC' |
naturalSorting | boolean | false |
Returns
Sorting
Defined in
packages/admin-sdk/src/data/Criteria.ts:611
naturalSorting
▸ Static
naturalSorting(field
, order?
): Sorting
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting. Allows to sort the documents by the provided field naturally
Parameters
Name | Type | Default value |
---|---|---|
field | string | undefined |
order | "ASC" | "DESC" | 'ASC' |
Returns
Sorting
Defined in
packages/admin-sdk/src/data/Criteria.ts:619
countSorting
▸ Static
countSorting(field
, order?
): Sorting
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\CountSorting. Allows to sort the documents by counting associations via the provided field
Sql representation: ORDER BY COUNT({field}) {order}
Parameters
Name | Type | Default value |
---|---|---|
field | string | undefined |
order | "ASC" | "DESC" | 'ASC' |
Returns
Sorting
Defined in
packages/admin-sdk/src/data/Criteria.ts:629
contains
▸ Static
contains(field
, value
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\ContainsFilter. This allows to filter documents where the value are contained in the provided field.
Sql representation: {field} LIKE %{value}%
Parameters
Name | Type |
---|---|
field | string |
value | string |
Returns
Object
Name | Type |
---|---|
type | "contains" |
field | string |
value | string |
Defined in
packages/admin-sdk/src/data/Criteria.ts:639
prefix
▸ Static
prefix(field
, value
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\PrefixFilter. This allows to filter documents where the value marks the beginning of the provided field.
Sql representation: {field} LIKE {value}%
Parameters
Name | Type |
---|---|
field | string |
value | string |
Returns
Object
Name | Type |
---|---|
type | "prefix" |
field | string |
value | string |
Defined in
packages/admin-sdk/src/data/Criteria.ts:649
suffix
▸ Static
suffix(field
, value
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\SuffixFilter. This allows to filter documents where the value marks the end of the provided field.
Sql representation: {field} LIKE %{value}
Parameters
Name | Type |
---|---|
field | string |
value | string |
Returns
Object
Name | Type |
---|---|
type | "suffix" |
field | string |
value | string |
Defined in
packages/admin-sdk/src/data/Criteria.ts:659
equalsAny
▸ Static
equalsAny(field
, value
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsAnyFilter. This allows to filter documents where the field matches one of the provided values
Sql representation: {field} IN ({value}, {value})
Parameters
Name | Type |
---|---|
field | string |
value | (null | string | number | boolean )[] |
Returns
Object
Name | Type |
---|---|
type | "equalsAny" |
field | string |
value | string |
Defined in
packages/admin-sdk/src/data/Criteria.ts:669
range
▸ Static
range(field
, range
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\RangeFilter. This allows to filter documents where the field matches a defined range
Sql representation: {field} >= {value}
, {field} <= {value}
, ...
Parameters
Name | Type |
---|---|
field | string |
range | Object |
range.lte? | string |
range.lt? | string |
range.gte? | string |
range.gt? | string |
Returns
Object
Name | Type |
---|---|
type | "range" |
field | string |
parameters | { lte? : string ; lt? : string ; gte? : string ; gt? : string } |
parameters.lte? | string |
parameters.lt? | string |
parameters.gte? | string |
parameters.gt? | string |
Defined in
packages/admin-sdk/src/data/Criteria.ts:679
equals
▸ Static
equals(field
, value
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter. This allows to filter documents where the field matches a defined range
Sql representation: {field} = {value}
Parameters
Name | Type |
---|---|
field | string |
value | null | string | number | boolean |
Returns
Object
Name | Type |
---|---|
type | "equals" |
field | string |
value | null | string | number | boolean |
Defined in
packages/admin-sdk/src/data/Criteria.ts:689
not
▸ Static
not(operator
, queries?
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\NotFilter. This allows to filter documents which not matches for the provided filters All above listed queries can be provided (equals, equalsAny, range, contains)
Sql representation: NOT({query} {operator} {query} {operator} {query})
Parameters
Name | Type | Default value | Description |
---|---|---|---|
operator | "and" | "AND" | "or" | "OR" | undefined | and/or |
queries | SingleFilter [] | [] |
Returns
Object
Name | Type |
---|---|
type | "not" |
operator | "and" | "AND" | "or" | "OR" |
queries | SingleFilter [] |
Defined in
packages/admin-sdk/src/data/Criteria.ts:705
multi
▸ Static
multi(operator
, queries?
): Object
See
\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\NotFilter. This allows to filter documents which matches for the provided filters All above listed queries can be provided (equals, equalsAny, range, contains)
Sql representation: ({query} {operator} {query} {operator} {query})
Parameters
Name | Type | Default value | Description |
---|---|---|---|
operator | "and" | "AND" | "or" | "OR" | undefined | and/or |
queries | SingleFilter [] | [] |
Returns
Object
Name | Type |
---|---|
type | "multi" |
operator | "and" | "AND" | "or" | "OR" |
queries | SingleFilter [] |
Defined in
packages/admin-sdk/src/data/Criteria.ts:721