---
title: "Querying Entities with FlowEngine (Query Static and Query Dynamic Nodes)"
canonical: "https://onesaitplatform.refined.site/space/DOCT/2220836706/Querying%20Entities%20with%20FlowEngine%20(Query%20Static%20and%20Query%20Dynamic%20Nodes)"
format: markdown
---
> Macro (toc)

This guide describes the Query Static and Query Dynamic nodes, showing examples for each. The methodology that follows the guide is the creation of an ontology, definitions of the queries and creation of the flow in FlowEngine.

# Creation of the Entity (Ontology)

Start by creating an ontology called queryNoderedTest. Using the Creation Step by Step option, add the field "field", type string; and the field "value" of number type. Update the scheme and generate the instance.


##### **queryNoderedTest ontology JSON**

```plaintext
{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "queryNoderedTest",
    "type": "object",
    "required": [
        "queryNoderedTest"
    ],
    "properties": {
        "queryNoderedTest": {
            "type": "string",
            "$ref": "#/datos"
        }
    },
    "datos": {
        "description": "Info queryNoderedTest",
        "type": "object",
        "required": [
            "field",
            "value"
        ],
        "properties": {
            "field": {
                "type": "string"
            },
            "value": {
                "type": "number"
            }
        }
    },
    "description": "Creation of an ontology for the ues of query nodes in the Flow Engine.",
    "additionalProperties": true
}
```

You can insert data using the CRUD of the ontology itself or using the FlowEngine and its [Insert](https://onesaitplatform.atlassian.net/wiki/spaces/DOCT/pages/2220838672) node.

# Query Static node definition

![image](media://048fe0b2-5b92-4a21-b8f2-d6d0b3f2c445)

A static query is based on the information added at the time of creation. Once the initial data is established, the fields cannot be modified.

Through this node, you can make several types of requests, both for data and for information, such as: **select, update** and **delete.**

# Query Dynamic node definition

![image](media://201951f0-e280-43a4-9ac5-9cc339692c7d)

In a dynamic query, the information can be updated at any time. As with the static query, the requests that can be made are query, updated and deleted.

# Flow creation in FlowEngine

## Flow with Query Static

Start with the creation of a flow with **static query.** The nodes to be used are:

- **Inject. **Activates the flow manually or at intervals.
- **Query Static. **Used to perform the query with static databases.
- **Debug. **Monitors the messages.

  


**In the Debug node, the *****msg.***** option is changed by *****complete msg object. ***The result that is obtained in the payload is a text message with the ontology's information. If you want to convert it to an object, you must make a parse object.

**In the Debug node, the *****msg.***** option is changed by *****complete msg object. ***The result that is obtained in the payload is a counter with the amount of objects that have been modified. In this example, only one value is modified.

**In the Debug node, the *****msg.***** option is changed by *****complete msg object. ***The result that is obtained in the payload is a counter with the amount of objects that have been deleted. In this example, only one value is deleted.

![image](media://8d43f790-3d5e-4bbb-8189-3dffe5d852a7)

## Flow with Query Dynamic

Start with the creation of a flow with **dynamic query.** The nodes to be used are:

- **Inject. **Activates the flow manually or at intervals.
- **Function.** JavaScript function against messages received by the node.
- **Query Static. **Used to perform the query with static databases.
- **Debug. **Monitors the messages.


In the window of the query dynamic node, the name that the node will take is entered, in this case, Dynamic query. The Debug option is also changed from *msg* to *complete msg object.*

In this case, the query has been done with *select* but, as in the static case, you can write a query with *update *or *delete.*

The Inject node needs to be configured. In payload, choose the JSON option and enter the data you want to search. In the Function node, write *msg.payload.filtro*, so that, when writing the field in Inject, it will be done with* filtro.* The result would be: Payload: {"filtro": 28.6}.

Click on Deploy and the flow is executed. The result you get as payload is an empty set since the search value, 28.6, is not included in the data.