# `Logistiki.BusinessEntities.BusinessEntityClosure`
[🔗](https://github.com/thanos/logistiki/blob/v0.1.0/lib/logistiki/business_entities/business_entity_closure.ex#L1)

Closure table for the business entity hierarchy.

Each row records that `ancestor` is an ancestor of `descendant` at `depth`.
A self-row has depth 0. The closure table is maintained by
`Logistiki.BusinessEntities` on insert and move.

## Fields

  * `id` — `integer()` — primary key (e.g. `1`)
  * `ancestor_id` — `integer()` — the ancestor entity id (e.g. `1` for Acme Holdings)
  * `descendant_id` — `integer()` — the descendant entity id (e.g. `2` for Acme Trading Ltd)
  * `depth` — `integer()` — 0 for self, 1 for direct child, 2 for grandchild (e.g. `1`)
  * `inserted_at` — `DateTime.t() | nil` — set on insert (no `updated_at`; e.g. `~U[2026-07-07 12:00:00Z]`)

## Example

    %Logistiki.BusinessEntities.BusinessEntityClosure{
      id: 1,
      ancestor_id: 1,    # Acme Holdings
      descendant_id: 2,  # Acme Trading Ltd
      depth: 1,
      inserted_at: ~U[2026-07-07 12:00:00Z]
    }

# `t`

```elixir
@type t() :: %Logistiki.BusinessEntities.BusinessEntityClosure{
  __meta__: term(),
  ancestor_id: integer() | nil,
  depth: integer() | nil,
  descendant_id: integer() | nil,
  id: integer() | nil,
  inserted_at: DateTime.t() | nil
}
```

The `BusinessEntityClosure` struct type.

A row in the closure table recording that `ancestor_id` is an ancestor of
`descendant_id` at the given `depth`.

## Fields

  * `id` — `integer() | nil` — primary key
  * `ancestor_id` — `integer() | nil` — ancestor entity id (e.g. `1`)
  * `descendant_id` — `integer() | nil` — descendant entity id (e.g. `2`)
  * `depth` — `integer() | nil` — 0 for self, 1 for child, 2 for grandchild
  * `inserted_at` — `DateTime.t() | nil` — set on insert

## Example

    %Logistiki.BusinessEntities.BusinessEntityClosure{
      ancestor_id: 1, descendant_id: 2, depth: 1
    }

---

*Consult [api-reference.md](api-reference.md) for complete listing*
