> For the complete documentation index, see [llms.txt](https://docs.cosmocloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cosmocloud.io/flow-builder/cql-cosmocloud-query-language/building-conditions.md).

# Building Conditions

Conditions are JSON like objects which process and return a **boolean** output at the runtime. An expressions object looks like -

## Syntax

The condition can be build in 2 types -

* [Simple Condition](#simple-condition)
* [Compound Condition](#compound-condition)

### Simple Condition

This condition has **at most one** condition comparison key.

```json
{
    <key>: {
        <operator>: <value>
    }
}
```

#### Properties

| Field       | Description                                                                                                                                                                                                                                                | Required |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| \<key>      | <p>The key which needs to be compared with the value.<br><br>This can also be a Magical Autocomplete.</p>                                                                                                                                                  | true     |
| \<operator> | A CQL conditional operator which defines what type of comparison has to be done in this condition object. You can check the list of CQL conditions operators [<mark style="color:blue;">**here**</mark>](#list-of-conditional-operators-available-in-cql). | true     |
| \<value>    | <p>The value to compare the <code>\<key></code> with.<br><br>This can also be a Magical Autocomplete.</p>                                                                                                                                                  |          |

### Compound Condition

This condition can compound together multiple Simple and Compound Conditions together.

```
{
    <compound_operator>: [ <cond>, <cond>, ... ]
}
```

#### Properties

| Field                 | Description                                                                                                                                                                                                                                                     | Required |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| \<compound\_operator> | A CQL compound operator which defines what type of comparison has to be done between the list of nested conditions. You can check the list of CQL compound operators [<mark style="color:blue;">**here**</mark>](#list-of-compound-operators-available-in-cql). | true     |
| \<cond>               | A nested Simple Condition object or Compound Condition object.                                                                                                                                                                                                  | true     |

## Examples

### Simple Conditions

```json
{
    "$.variables.name": {
        "$eq": "Shrey"
    }
}
```

The above expression will return **true** if the variable `name` contains the value **Shrey** else will return **false**.

### Compound Conditions

The below snippet shows how you can build the query -&#x20;

```python
# Sample query to be built
name=Shrey OR age=10
```

```json
// Condition Object
{
    "$or": [
        {
            "$.variables.name": {
                "$eq": "Shrey"
            }
        },
        {
            "$.variables.age": {
                "$eq": 10
            }
        }
    ]

}
```

### Multiple Level of Conditions

The below snippet shows how you can build the query -&#x20;

```python
# Sample query to be built
name=Shrey OR (age>25 AND marks >=80)
```

```json
// Condition Object
{
    "$or": [
        {
            "$.variables.name": {
                "$eq": "Shrey"
            }
        },
        {
            "$and": [
                {
                    "$.variables.age": {
                        "$gt": 25
                    }
                },
                {
                    "$.variables.marks": {
                        "$gte": 80
                    }
                }
            ]
        }
    ]

}
```

List of Compound Operators available in CQL -

* [$and](/flow-builder/cql-cosmocloud-query-language/building-conditions/compound-operators/usdand.md)
* [$or](/flow-builder/cql-cosmocloud-query-language/building-conditions/compound-operators/usdor.md)

List of Conditional Operators available in CQL -

* [$eq](/flow-builder/cql-cosmocloud-query-language/building-conditions/conditional-operators/usdeq.md)
* [$neq](/flow-builder/cql-cosmocloud-query-language/building-conditions/conditional-operators/usdneq.md)
* [$lt](/flow-builder/cql-cosmocloud-query-language/building-conditions/conditional-operators/usdlt.md)
* [$lte](/flow-builder/cql-cosmocloud-query-language/building-conditions/conditional-operators/usdlte.md)
* [$gt](/flow-builder/cql-cosmocloud-query-language/building-conditions/conditional-operators/usdgt.md)
* [$gte](/flow-builder/cql-cosmocloud-query-language/building-conditions/conditional-operators/usdgte.md)
