From 039d219031db44c2a915456cd42b1db0f2487d9b Mon Sep 17 00:00:00 2001 From: Tomasz Kowal Date: Sun, 22 Dec 2024 13:23:05 +0000 Subject: [PATCH] Document usage of ParametrizedType inside of a composite type --- lib/ecto/parameterized_type.ex | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/ecto/parameterized_type.ex b/lib/ecto/parameterized_type.ex index 0fab2f08e8..187b7a9b0b 100644 --- a/lib/ecto/parameterized_type.ex +++ b/lib/ecto/parameterized_type.ex @@ -64,6 +64,13 @@ defmodule Ecto.ParameterizedType do field :bar, MyApp.MyType, opt1: :baz, opt2: :boo end + To use this type in a schema field with a composite type, specify the type in a tuple + and opts afterwards. + + schema "foo" do + field :bars, {:array, MyApp.MyType}, opt1: :baz, opt2: :boo + end + To use this type in places where you need it to be initialized (for example, schemaless changesets), you can use `init/2`.