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 @ 0b7c8524
[[_TOC_]]
The **attrs** parameter is for attributes like sorting, joining and column definitions. The **attrs** parameter is for attributes like sorting, joining and column definitions.
https://metacpan.org/pod/distribution/DBIx-Class/lib/DBIx/Class/ResultSet.pm#ATTRIBUTES https://metacpan.org/pod/distribution/DBIx-Class/lib/DBIx/Class/ResultSet.pm#ATTRIBUTES
...@@ -5,7 +7,7 @@ https://metacpan.org/pod/distribution/DBIx-Class/lib/DBIx/Class/ResultSet.pm#ATT ...@@ -5,7 +7,7 @@ https://metacpan.org/pod/distribution/DBIx-Class/lib/DBIx/Class/ResultSet.pm#ATT
The IronAPI supports these options: The IronAPI supports these options:
- [join and prefetch](#join-and-prefetch) - [join and prefetch](#join-and-prefetch)
- (+)columns - [(+)columns](#columns)
- (+)select - (+)select
- (+)as - (+)as
- order_by - order_by
...@@ -32,9 +34,7 @@ Only references may be joined/prefetched. There are two ways to do this, dependi ...@@ -32,9 +34,7 @@ Only references may be joined/prefetched. There are two ways to do this, dependi
## An attribute of an entity is a reference to an attribute of another entity ## An attribute of an entity is a reference to an attribute of another entity
Use the attribute name to join or prefetch it: Use the attribute name to join or prefetch it - system.entity.module is a reference to system.module.id:
system.entity.module is a reference to system.module.id:
`POST /data/sytem/entity/query` `POST /data/sytem/entity/query`
...@@ -46,11 +46,9 @@ system.entity.module is a reference to system.module.id: ...@@ -46,11 +46,9 @@ system.entity.module is a reference to system.module.id:
This fetches all the details of the linked module entry to each entity entry. This fetches all the details of the linked module entry to each entity entry.
## An attribute of an entity is being references by another attibute of a different entity ## An attribute of an entity is being references by another attribute of a different entity
Use `$model__$entity__$attribute` to join it: Use `$model__$entity__$attribute` to join it - system.module.id is being referenced by system.entity.module:
system.module.id is being referenced by system.entity.module:
`POST /data/system/module/query` `POST /data/system/module/query`
...@@ -65,20 +63,16 @@ This fetches all entity entries for a module and lists them under the module. ...@@ -65,20 +63,16 @@ This fetches all entity entries for a module and lists them under the module.
## Restrictions ## Restrictions
Keys and values may not contain spaces. Keys and values may not contain spaces and must be found in the universe of the user.
## Examples ## Examples
Combined with query conditions: Combined with query conditions:
(This will get all transitions which have the instance as pre_state and whose post_state is 2) (This will get all transitions which have the instance as pre_state and whose post_state is 2)
```JSON `POST /data/system/state/query`
#/data/system/state/query ```json
{ {
"conds" : {"system__transition__pre_state.post_state" : 2 }, "conds" : {"system__transition__pre_state.post_state" : 2 },
"attrs": {"prefetch" : "system__transition__pre_state"} "attrs": {"prefetch" : "system__transition__pre_state"}
...@@ -91,9 +85,9 @@ be used in the search condition and only specific columns may be returned. ...@@ -91,9 +85,9 @@ be used in the search condition and only specific columns may be returned.
(select all columns from system.state and return only system.transition.name (select all columns from system.state and return only system.transition.name
using system_transition_pre_state.post_state as search condition) using system_transition_pre_state.post_state as search condition)
```JSON `POST /data/system/state/query`
#/data/system/state/query
```json
{ {
"conds" : {"system__transition__pre_state.post_state" : 2 }, "conds" : {"system__transition__pre_state.post_state" : 2 },
"attrs": { "attrs": {
...@@ -105,9 +99,8 @@ be used in the search condition and only specific columns may be returned. ...@@ -105,9 +99,8 @@ be used in the search condition and only specific columns may be returned.
Joins and prefetches can be nested as deeply as needed: Joins and prefetches can be nested as deeply as needed:
```JSON `POST #/data/system/state/query`
#/data/system/state/query ```json
{ {
"attrs": { "prefetch" : [ "modifying_client", "attrs": { "prefetch" : [ "modifying_client",
{ "system__transition__pre_state" : "entity" } { "system__transition__pre_state" : "entity" }
...@@ -120,7 +113,64 @@ More documentation on joining can be found here: ...@@ -120,7 +113,64 @@ More documentation on joining can be found here:
<https://metacpan.org/pod/release/RIBASUSHI/DBIx-Class-0.082840/lib/DBIx/Class/Manual/Joining.pod> <https://metacpan.org/pod/release/RIBASUSHI/DBIx-Class-0.082840/lib/DBIx/Class/Manual/Joining.pod>
### Ordering # Columns
`columns` defines which attributes should be fetched.
## Restrictions
Values may not contain spaces and must be present in the users universe.
## Examples
### columns
Get only two columns of the base entity:
`POST /data/system/entity/query`
```json
{
"attrs": {
"columns": [
"id",
"name"
]
}
}
```
To get only one column from a joined entity:
`POST /data/system/entity/query`
```json
{
"attrs": {
"join": "module",
"columns": [
"module.name"
]
}
}
```
### +columns
Use `+columns` to get all columns of the base table plus certain ones from joined tables:
```json
{
"attrs": {
"join": "module",
"+columns": [
"module.name"
]
}
}
```
# Ordering
RESTRICTIONS: keys and values may not contain spaces. RESTRICTIONS: keys and values may not contain spaces.
...@@ -147,7 +197,7 @@ More details can be found here: ...@@ -147,7 +197,7 @@ More details can be found here:
<https://metacpan.org/pod/distribution/DBIx-Class/lib/DBIx/Class/ResultSet.pm#order_by> and <https://metacpan.org/pod/distribution/DBIx-Class/lib/DBIx/Class/ResultSet.pm#order_by> and
<https://metacpan.org/pod/release/ILMARI/SQL-Abstract-1.84/lib/SQL/Abstract.pm#ORDER_BY_CLAUSES> <https://metacpan.org/pod/release/ILMARI/SQL-Abstract-1.84/lib/SQL/Abstract.pm#ORDER_BY_CLAUSES>
### Naming Conventions # Naming Conventions
When referencing to a column, the name without the table prefix can be used as long as it is unique within When referencing to a column, the name without the table prefix can be used as long as it is unique within
the query. Otherwise, the table name (as used for joining the table) needs to be prefixed: the query. Otherwise, the table name (as used for joining the table) needs to be prefixed:
...@@ -165,27 +215,7 @@ for joined/prefetched tables use their name as a prefix: ...@@ -165,27 +215,7 @@ for joined/prefetched tables use their name as a prefix:
} }
``` ```
### Columns # Select and As
RESTRICTIONS: keys and values may not contain spaces.
To get only the columns from a joined table:
```JSON
"attrs" : {
"join" :"contracts__working_contract",
"columns" : ["contracts__working_contract.working_hours_per_week","contracts__working_contract.salary"]
}
```
Use "+columns" to get all columns of the base table plus certain ones from joined tables:
```JSON
"join" : "contracts__working_contract",
"+columns" : ["contracts__working_contract.working_hours_per_week"]}
```
### Select and As
RESTRICTIONS: keys and values may not contain spaces. RESTRICTIONS: keys and values may not contain spaces.
...@@ -219,7 +249,7 @@ Returns one row: ...@@ -219,7 +249,7 @@ Returns one row:
<https://metacpan.org/pod/distribution/DBIx-Class/lib/DBIx/Class/ResultSet.pm#select> <https://metacpan.org/pod/distribution/DBIx-Class/lib/DBIx/Class/ResultSet.pm#select>
### Collapse # Collapse
When "collape" is set to a true value, indicates that any rows fetched from joined has_many relationships 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: are to be aggregated into the corresponding "parent" object:
......
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