| ... | ... | @@ -13,7 +13,7 @@ The IronAPI supports these options: |
|
|
|
- [order_by](#ordering)
|
|
|
|
- [group_by](#group-by)
|
|
|
|
- [collapse](#collapse)
|
|
|
|
- having
|
|
|
|
- [having](#having)
|
|
|
|
|
|
|
|
|
|
|
|
This document will cover some of the options with specific examples.
|
| ... | ... | @@ -447,6 +447,10 @@ A list of how many users have which value in the json attribute `settings->>'en |
|
|
|
When "collape" is set to a true value, indicates that any rows fetched from joined has_many relationships
|
|
|
|
are to be aggregated into the corresponding "parent" object:
|
|
|
|
|
|
|
|
Note that "prefetch" is a shortcut for "join", adding all columns from the joined related sources as "+columns" and setting "collapse" to a true value.
|
|
|
|
|
|
|
|
https://metacpan.org/pod/distribution/DBIx-Class/lib/DBIx/Class/ResultSet.pm#collapse
|
|
|
|
|
|
|
|
## Restrictions
|
|
|
|
|
|
|
|
The only valid values are `0` and `1`.
|
| ... | ... | @@ -529,9 +533,46 @@ Without "collapse", there would be an entry for each module+entity combination: |
|
|
|
|
|
|
|
````
|
|
|
|
|
|
|
|
Note that "prefetch" is a shortcut for "join", adding all columns from the joined related sources as "+columns" and setting "collapse" to a true value.
|
|
|
|
# Having
|
|
|
|
|
|
|
|
`having` specifies a search condition for a group or an aggregate.
|
|
|
|
|
|
|
|
For filtering with a function, this format is supported: `{'count(id)' => {"!=", 1}}`. It will be translated to
|
|
|
|
SQL `\[ 'count(id) != ?', 100 ]`. Only (permitted functions)[#permitted-functions] may be called.
|
|
|
|
|
|
|
|
https://metacpan.org/pod/DBIx::Class::ResultSet#having
|
|
|
|
|
|
|
|
## Restrictions
|
|
|
|
|
|
|
|
Only (permitted functions)[#permitted-functions] may be called. As operators, `!=`. `=`, `<` , `<=`, `>` and `>=` are currently supported.
|
|
|
|
The value for the comparison must be integer.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
List only those modules which have entites attached:
|
|
|
|
|
|
|
|
`POST /data/system/module/query`
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"attrs": {
|
|
|
|
"join": "system__entity__module",
|
|
|
|
"columns": "me.name",
|
|
|
|
"+select": [
|
|
|
|
{
|
|
|
|
"count": "system__entity__module.id",
|
|
|
|
"-as" : "entity_count"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"+as": [
|
|
|
|
"entity_count"
|
|
|
|
],
|
|
|
|
"group_by": "me.name",
|
|
|
|
"having" : {"count(system__entity__module.id)" : {">" : 0}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
https://metacpan.org/pod/distribution/DBIx-Class/lib/DBIx/Class/ResultSet.pm#collapse
|
|
|
|
|
|
|
|
# Permitted Column Names
|
|
|
|
|
| ... | ... | |