Caravela.Gen.Context (Caravela v0.7.0)

Copy Markdown View Source

Generates a Phoenix context module for a Caravela.Schema.Domain.

The module lives at lib/<app>/<context>.ex (e.g. lib/my_app/library.ex) and exposes the standard Phoenix CRUD functions per entity:

  • list_<plural>/1
  • get_<singular>/2, get_<singular>!/2
  • change_<singular>/2
  • create_<singular>/2
  • update_<singular>/3
  • delete_<singular>/2

Every write path runs the corresponding on_create/on_update/ on_delete hook and can_* permission declared on the domain. Reads scope through can_read automatically.

Read paths (list_*, get_*, get_*!) preload every belongs_to association declared on the entity so the generated Svelte components can follow book.author.name without tripping over %Ecto.Association.NotLoaded{} structs on the wire.

Returns a single {path, source} tuple. Regeneration preserves anything below the # --- CUSTOM --- marker.

Summary

Functions

Render the context file for the domain.

Functions

render(domain, opts \\ [])

Render the context file for the domain.