Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Apr 8, 2020
1 parent 7ac6e75 commit 38b66d1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/ecto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,16 @@ defmodule Ecto do
Ecto.Schema.Loader.unsafe_load(schema_or_types, data, &Ecto.Type.embedded_load(&1, &2, format))
end

@doc """
Dumps the given struct defined by an embedded schema.
This converts the given embedded schema to a map to be serialized
with the given format. For example:
iex> Ecto.embedded_dump(%Post{}, :json)
%{title: "hello"}
"""
@spec embedded_dump(Ecto.Schema.t(), format :: atom()) :: map()
def embedded_dump(%schema{} = data, format) do
Ecto.Schema.Loader.safe_dump(data, schema.__schema__(:dump), &Ecto.Type.embedded_dump(&1, &2, format))
Expand Down
15 changes: 14 additions & 1 deletion lib/ecto/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,20 @@ defmodule Ecto.Repo do
* `:telemetry_options` - Extra options to attach to telemetry event name.
See the next section for more information
### Telemetry events
## Telemetry events
There are two types of telemetry events. The ones emitted by Ecto and the
ones that are adapter specific.
### Ecto telemetry events
The following events are emitted by all Ecto repositories:
* `[:ecto, :repo, :init]` - it is invoked whenever a repository starts.
The measurement is a single `system_time` entry in native unit. The
metadata is the `:repo` and all initialization options under `:opts`.
### Adapter-specific events
We recommend adapters to publish certain `Telemetry` events listed below.
Those events will use the `:telemetry_prefix` outlined above which defaults
Expand Down

0 comments on commit 38b66d1

Please sign in to comment.