Querying by model
In this section, we will explain how you can query by model. Each digital twin is derived from a model. The Query API allows us to use the IS_OF_MODEL
operator. The definition of such a query is shown in the following:
SELECT * FROM DIGITALTWINS <Collection> WHERE IS_OF_MODEL( <Collection>, <ModelId>, <Exact>)
The IS_OF_MODEL
operator can have up to three parameters. Each of the parameters is explained here:
We will explain the results of using these parameters in several examples using the IS_OF_MODEL
operator. We start by defining the <ModelId>
. Enter the following query in the Query field, and click the Run Query button in Azure Digital Twins Explorer:
SELECT * FROM DIGITALTWINS WHERE IS_OF_MODEL('dtmi:com:smartbuilding:Room;1')
This query specifies to return all digital twins that are based on the Room
model. The result is shown in Figure 7.13: