diff --git a/lib/ecto/json.ex b/lib/ecto/json.ex index 1112bdc6cc..b28c5d462e 100644 --- a/lib/ecto/json.ex +++ b/lib/ecto/json.ex @@ -17,6 +17,9 @@ if Code.ensure_loaded?(Jason.Encoder) do @derive {Jason.Encoder, only: [:name, :title, ...]} schema ... do + + You can also use the :except option instead of :only if you would \ + prefer to skip some fields. """ end end @@ -29,13 +32,16 @@ if Code.ensure_loaded?(Jason.Encoder) do exposed externally. You can either map the schemas to remove the :__meta__ field before \ - encoding to JSON, or explicitly list the JSON fields in your schema: + encoding or explicitly list the JSON fields in your schema: defmodule #{inspect(schema)} do # ... @derive {Jason.Encoder, only: [:name, :title, ...]} schema ... do + + You can also use the :except option instead of :only if you would \ + prefer to skip some fields. """ end end