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
x authored Jan 21, 2022 by Andrea Pavlovic's avatar Andrea Pavlovic
Hide whitespace changes
Inline Side-by-side
API/Queries/Attributes.md
View page @ 73ba8cd2
......@@ -172,31 +172,78 @@ Use `+columns` to get all columns of the base table plus certain ones from joine
# Select and As
RESTRICTIONS: keys and values may not contain spaces.
The "select" and "as" attribues allow even more flexibility to define exactly what should be returned than "columns" does. Other than renaming a column,
functions may be used to select calculated values.
The "select" and "as" attribues allow even more flexibility to define exactly what should be returned than "columns" does.
## Restrictions
```JSON
"attrs" : {
"join": [ "contracts__working_time_constraint" ],
"select": [ {"min" : "max_hours_per_day"} ],
"as": [ "min_max" ]
Keys and values may not contain spaces.
## Examples
Only select one column and name it "me_id" from system.entity:
`POST /data/system/entity/query`
```json
{
"attrs": {
"select": "me.id",
"as": "me_id"
}
}
```
Result:
```json
{
"data": [
{
"me_id": 1
},
{
"me_id": 2
}
]
}
```
Select the maximum id from system.entity:
`POST /data/system/entity/query`
```json
{
"attrs": {
"select": [
{
"max": "me.id"
}
],
"as": [
"max_id"
]
}
}
}
```
Generates:
```SQL
SELECT MIN( max_hours_per_day )
FROM contracts.collective_agreement() me
LEFT JOIN contracts.working_time_constraint() contracts_working_time_constraint ON contracts_working_time_constraint.collective_agreement = me.id
LIMIT 10
```sql
SELECT MAX( me.id ) FROM system.entity()
```
Returns one row:
```JSON
```json
{
"min_max": "9"
"data": [
{
"max_id": 99
}
]
}
```
......
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