> For the complete documentation index, see [llms.txt](https://docs.hormo.studio/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hormo.studio/models/relations.md).

# Relations

The `relations` key defines relationships between models. Hormo Studio managing relations in you back-end services by set options as relations configs easily as below:

![](/files/-Lz79H_glw47h_mpc9oL)

| Key        | Type            | Description                                                                                                       |
| ---------- | --------------- | ----------------------------------------------------------------------------------------------------------------- |
| foreignKey | String          | Optional foreign key used to find related model instances.                                                        |
| ref(model) | String          | Name of the related model. Required.                                                                              |
| type       | String          | <p>Relation type. Required</p><p><strong>hasMany</strong></p><p><strong>hasManyThrough and belongsTo</strong></p> |
| Filter     | Object/Function | You can filter a relationship field using the filters option. `{ "type": "user" }`                                |

{% content-ref url="/pages/-Lz7-hWbuZz4HAVvUyuY" %}
[Built-in User model](/models/built-in-user-model.md)
{% endcontent-ref %}
