# Querying Models

Queries are expressions that are used in a variety of places; selecting & filtering models, defining edge types & assertions.

Expressions used in the global scope return tables. For example, the following commands will display different views of the `User` table

```
> User

> User[name == "Ben"]

> User{ id, name }
```

Expressions used within the scope of a table generate a column. For example, a filter expression, an assertion expression, or computed column expression.

<pre><code><strong>> User{ full_name: first_name + ' ' + last_name }
</strong></code></pre>

## Expressions

Expressions support the basic operations:

* `+ - * / %` math
* `== != >= > < <=` comparison
* `! & | ^` logical (not, and, or, xor)
* `()` parenthesis

## Selecting

Use the curly brackets after a table expression to create a new view of that type, showing only the listed columns, able to define new computed columns, or define additional assertions for that view.

```
> User {
    id,
    full_name: first_name + ' ' + last_name
    assert id > 0
  }
```

## Filtering

Use square brackets after a table expression with a list of expressions that all must be true in order to be included in the resulting table.

```
> User[
    name == "Ben"
    country == "US"
  ]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kyelang.org/basics/models.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
