Using Services and Queries
In most cases, applications are not limited to CRUD operations with entities. CUBA REST API provides special endpoints for invoking middleware services and running predefined queries. These are places where you can put your business logic and invoke it from the front-end using the cuba-service and cuba-query components.
By default, the components automatically load data on initialization. You can disable this behavior by assigning false
to property auto
and calling load()
method programmatically.
Usage example
<cuba-query id="query"
entity-name="sec$User"
query-name="usersByName"
data="{{users}}">
</cuba-query>
...
<cuba-service service-name="cuba_ServerInfoService"
method="getReleaseNumber"
data="{{releaseNumber}}">
</cuba-service>
cuba-service-form can be used instead of cuba-service
when it’s semantically more correct to use form submit instead of information requests. However, it’s not mandatory, and under the hood they use the same REST API.