jyurek
Postgres column type for embeds_many
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?
Most Liked
LostKobrakai
https://robots.thoughtbot.com/why-ecto-s-way-of-storing-embedded-lists-of-maps-makes-querying-hard
tldr: it’s suggested because of older postgres version support
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









