|
|
|
The entity extensions.query is used to save queries. It takes the same arguments "attrs" and "conds" as [[General Queries]]. It is a normal entity, so all endpoints work as usual. The only difference is that the [[General Queries]] endpoint knows it is the entity where saved queries are stored.
|
|
|
|
|
|
|
|
To save a query, call
|
|
|
|
|
|
|
|
`/data/extensions/query/transitions/create`
|
|
|
|
|
|
|
|
```JSON
|
|
|
|
{
|
|
|
|
"entity": "98",
|
|
|
|
"name": "employee filter",
|
|
|
|
"conds": {"date_of_birth": {"<":"1994-03-28"}},
|
|
|
|
"atts": {},
|
|
|
|
"is_default": "FALSE",
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
this will return the query id which can then be used on the entity.
|
|
|
|
|
|
|
|
If `is_default` is set, it will be set as the new default search for the entity.
|
|
|
|
|
|
|
|
### Calling a query
|
|
|
|
|
|
|
|
`/data/$module/$entity/query?id=$id`
|
|
|
|
|
|
|
|
In addition to the id, the general paging parameters (limit, offset, page, page_size, no_filtered_count) can be used.
|
|
|
|
|
|
|
|
It is also possible to overload the search `conds` and the `order_by` flag, `attrs` will be ignored.
|
|
|
|
|
|
|
|
```
|
|
|
|
/data/$module/$entity/query?id=$id&conds={"id":"3"} -> works, returns entry with id=3
|
|
|
|
/data/$module/$entity/query?id=$id&order_by=$column -> works, returns list in that order
|
|
|
|
/data/$module/$entity/query?id=$id&attrs={"bla":"blubb"} -> does not work, attrs are ignored
|
|
|
|
```
|
|
|
|
|
|
|
|
### Invalid queries
|
|
|
|
|
|
|
|
A query can become invalid if the underlying database model changes. It will be flagged as invalid once it's been used and produced an error. A subsequent database model change sets all queries with is_valid=FALSE to is_valid=NULL and the query will be tested when it's next used. After that, it's is_valid flag is set again.
|
|
|
|
|
|
|
|
* is_valid=TRUE -> worked last time it was used
|
|
|
|
* is_valid=FALSE -> failed last time it was used
|
|
|
|
* is_valid=NULL -> state unknown after model change
|
|
|
|
|
|
|
|
### Caching
|
|
|
|
|
|
|
|
All queries are cached by the api, and get updated when there is a change. To rebuild the cache (at system startup or when there is a problem), execute:
|
|
|
|
|
|
|
|
script/cache_update.pl --no-create-schema-files --no-dump-errors |
|
|
|
\ No newline at end of file |