<commit_before># Definition

Models can refer to each other by using the other model's name as
`attribute.type` in their [schema definition](schema.md), either as a scalar
value or an array, for one-to-one or one-to-many relationship.

For example:

```yml
models:
  user:
    attributes:
      friend:
        type: user
      managers:
        type: user[]
```

Models can nest themselves, i.e. be recursive.

Nested attributes are using the `id` attribute of the model they refer to.

# Modifying nested models

Clients can modify nested models by using a nested `data` argument, e.g.:

```graphql
mutation {
  create_user(data: {
    id: "1"
    name: "Anthony"
    manager: {
      id: "3"
      name: "Anna"
    }
  }) {
    id
  }
}
```

will create both the user and its manager.

# Deleting nested models

To delete nested models, specify them using the `cascade` argument,
as a comma-separated list of nested models, e.g.:

```graphql
mutation {
  delete_user(id: "1", cascade: "manager.friend,colleague") {
    id
  }
}
```

will delete `user`, `user.manager.friend` and `user.colleague`.

# Populating nested models

Clients can populate nested models in output, e.g.:

```graphql
{
  find_user(id: "1") {
    id
    name
    manager {
      id
      name
    }
  }
}
```

will respond with:

```json
{
  "data": {
    "id": "1",
    "name": "Anthony",
    "manager": {
      "id": "3",
      "name": "Anna"
    }
  }
}
```

This is available for any command, including `delete`, `create`, etc.

Populating nested models in output is distinct from
[modifying](#modifying-nested-models) or [deleting](#deleting-nested-models)
nested models in input.<commit_msg>Update user documentation<commit_after># Definition

Models can refer to each other by using the other model's name as
`attribute.type` in their [schema definition](schema.md), either as a scalar
value or an array, for one-to-one or one-to-many relationship.

For example:

```yml
models:
  user:
    attributes:
      friend:
        type: user
      managers:
        type: user[]
```

Models can nest themselves, i.e. be recursive.

Nested attributes are using the `id` attribute of the model they refer to.

# Modifying nested models

Clients can modify nested models by using a nested `data` argument, e.g.:

```graphql
mutation {
  create_user(data: {
    id: "1"
    name: "Anthony"
    manager: {
      id: "3"
      name: "Anna"
    }
  }) {
    id
  }
}
```

will create both the user and its manager.

# Deleting nested models

To delete nested models, specify them using the `cascade` argument,
as a comma-separated list of nested models, e.g.:

```graphql
mutation {
  delete_user(id: "1", cascade: "manager.friend,colleague") {
    id
  }
}
```

will delete `user`, `user.manager.friend` and `user.colleague`.

# Populating nested models

Clients can populate nested models in output, e.g.:

```graphql
{
  find_user(id: "1") {
    id
    name
    manager {
      id
      name
    }
  }
}
```

will respond with:

```json
{
  "data": {
    "id": "1",
    "name": "Anthony",
    "manager": {
      "id": "3",
      "name": "Anna"
    }
  }
}
```

For write commands, only models already present in either the `data` or
`cascade` argument can be populated in output.
{'fraction_non_alphanumeric': 0.12396185788988004, 'fraction_numerical': 0.003691171947093202, 'mean_word_length': 2.9322853688029022, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5585242', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1057, 'n_words': 381}