phoebe
Hi,
I have another question about User schemas. Say, I have an eBay or marketplace type app, and a user who initially registers as a buyer on the site. In the code, there is a User schema with typical fields: :name, :string and :username, :string and a schema for BuyerProfile with the usual fields: delivery_address_1, delivery_address_2, delivery_zip_code, etc., and User has_one BuyerProfile profile relationship. I also create a BuyerProfile ‘belongs_to’ User relationship.
Later, the same user becomes a Seller as well, and then should have a has_one relationship with SellerProfile (SellerProfile schema could include fields like :tax_code, :string, etc.).. Is it preferable (scalable?) to maintain a user schema for some users, who could either have a buyer profile, or seller profile or both, as I can see that parts of the code will always have to do checks such as “if user has a buyer profile, then do this or show this…”? Or is it better to define a Role schema of Buyer, Seller and BuyerAndSeller and make a user belong_to a Role?
Thanks!
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming









