Using queries

You can use TQL queries in two ways:

(1) External Query:  Use queries from a client (external to the A-Stack). These queries are sent to the A-Stack query end points as the payload of a message. The query return will be send back to the client as a message. These queries can not only provide client the model instance data, but also execute business logic after the TQL Project has been deployed. For example, from find and update queries, the client would be able to view and control the states of things.


(2) Internal Query: Use queries within the models that are deployed to A-Stack itself. These queries execute business logic between the TQL Models themselves, independent of the client. They are included in ThingFacets and AppFacets as part of the Action/Task/Invoke (question).  For example, one model may try to update another model and that can be done by executing query as part of the action.

However, all queries are executed through the TQL FacetType.


TQL queries can contain two types of structures: 

(1) Standard structures: defined by the Query Language. They have their specific syntax and use. Including FIND, CREATE, SAVE, UPDATE, DELETE, DELETE ALL

(2) Extended structures: other ADL languages or language components can be used within queries. Typically, they include: constraints, Macros and FacetScript. You can also use JavaScript within queries (note - do we want to encourage?). See /wiki/spaces/TQLDocs/pages/1179674.