Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • A api
  • Project information
    • Project information
    • Activity
    • Members
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Wiki
    • Wiki
  • Activity
Collapse sidebar
  • ironapi
  • api
  • Wiki
  • Api
  • Queries
  • Attributes

Attributes · Changes

Page history
attrs docu authored Jan 25, 2022 by Andrea Pavlovic's avatar Andrea Pavlovic
Hide whitespace changes
Inline Side-by-side
API/Queries/Attributes.md
View page @ 38fff2c4
......@@ -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
......
Clone repository
  • API
    • Available Endpoints
    • Changing Passwords
    • Form Input Types
    • Introduction
    • Logout
    • Plugins
    • Queries
    • Queries
      • Attributes
      • Context
      • Query Examples
      • Query Search Options
      • Referenced Instances
      • Saved Queries
    • Schema_Changes
    • Storing Files
View All Pages