In TQL, a query is any operations on the model instance data (or model data), which includes filtering, joining, viewing and manipulation of data. (definition data, instance data). Definition data is
Instance data always return the latest version. Known value is also returned if asked "All".
Is the data in store or data in memory? (stored) Agnostic to the database technology, stored as key value pairs
How is the data saved?
How is the data structured? No relational structure.
How is the data retrieved? When a query is executed, the TQLEngine will identify the model definition, and use it to construct the database query to retrieve the requested data or perform necessary CRUD operations.
in the mqp file, you define query end points. Query end points are channels to communicate through the TQLFacet instance with the TQLEngine.
Usually studio automatically generate the mqp file, which define two query end points:
http:// - for all queries except subscription. Sync (timeout?)
ws:// - subscription is always sent and received from the ws. Async
Describe the common structure of a query end point.
When a project is deployed onto a TQL Engine, it always creates two end points
Queries are sent to end points as payload of a message.
What about the Query End Points?
When to use queries, what are the different ways
(1) from the app (client to TQLEngine) - external (needs query end point), - return will be sent as message back to client
(2) from model facet, invoke - internal (the return will be the output of the invoke).
What can go inside a query
Does query only change value, not known value
What is the common structure of a query
What are the most basic types of queries?
What is the lifecycle of a queryand manipulations. Model instances are incarnations of the Models (or model definitions) through instantiation. The A-Stack stores the latest version of the model instance data, which is accessible to TQL Queries. See data storage for more details.
There is a special type of query which allows you to show or list the model definitions themselves. See /wiki/spaces/TQLDocs/pages/1179668 for details.
Like conventional queries, TQL queries perform CRUD operations on data. but unlike conventional database queries, TQL queries are:
(1) Current. The A-Stack maintains the latest versions of any attribute values and attribute known values based on the model definitions. For example, the latest reading of a temperature sensor value. TQL queries always return those latest versions.
(2) Model-driven. Since the model definitions define the structure of the model data, the A-Stack constructs the database queries based on the model definition to retrieve requested data or perform other CRUD operations. The model definition is NOT the data schema. Model instance data are saved in schemaless key value pairs.
(3) Actionable. Modifications of model data via TQL queries, if involving actionable attributes, can result in activation of actions, some of which may subsequently execute device actuations.
Each model attribute has both a value and a known value. Although you can "FIND" both values and known values of model attributes, you can only set values but not known values from queries. This is because the known values are reserved to be updated only by the result of Actions, which comes from external systems or external things.
TQL queries have the following standard structures:
FIND CREATE SAVE UPDATE DELETE DELETEALL
In addition, you can use other operations such as conditions/constraints, response modifications, iterations, etc. within the queries.