# `PgRest.Plan.Embed`
[🔗](https://github.com/agoodway/pgrest/blob/v0.2.0/lib/pg_rest/planner/plan.ex#L233)

An embedded resource: the relationship from the parent, the JSON output name and the
plan of the target. `join_conditions` are the equalities that tie the target to its parent,
resolved by the planner as `{left_alias, left_field, right_alias, right_field}` over the
exposed (Ecto field) column names. `agg_alias` (`"pgrst_e<n>"`, numbered per statement so
it never exceeds 63 bytes) names the lateral that holds the embed's rows, and
`junction_alias` and `junction_source_query` the junction of a many-to-many embed.

A spread whose target subtree has an `after_load/2` resource is planned with
`merge: true` and `spread: false`: SQL renders it as a plain embed under its `merge_key`
(`"...m<n>"`, generated, never a request name), and `PgRest.Responder` runs `after_load/2` on its rows before merging the columns into
the parent (to-one) or into per-column arrays (to-many).

# `t`

```elixir
@type t() :: %PgRest.Plan.Embed{
  agg_alias: String.t() | nil,
  join: :left | :inner,
  join_conditions: [{String.t(), String.t(), String.t(), String.t()}],
  junction_alias: String.t() | nil,
  junction_policy: map() | nil,
  junction_source_query: Ecto.Query.t() | nil,
  merge: boolean(),
  merge_key: String.t() | nil,
  output_name: String.t(),
  plan: PgRest.Plan.Read.t(),
  relationship: PgRest.SchemaGraph.Relationship.t(),
  spread: boolean()
}
```

# `to_one?`

```elixir
@spec to_one?(t()) :: boolean()
```

Whether the embed yields one object (`m2o`, `o2o`) rather than an array.

---

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