Everywhere I’ve seen a blog post, etc. about making a column in postgres for an embeds_many
, I see the same advice: use add :column, {:array, :map}, default: []
in the migration.
But this creates a postgres array of jsonb objects. This is not sensible to query on.
In my testing, I’ve found that simply using a :jsonb
type for the column is sufficient and correct for everything embeds_many
can do. It can leverage all the power of postgres’ jsonb type as well.
So here’s the question: If everyone is suggesting {:array, :map}
and that seems to be inadequate for the purposes of doing standard database things, am I wrong for using :jsonb
? Is there something about this that I’m overlooking?