Closed joeljuca closed 3 months ago
Maybe it be like
defmodule MyApp.Accounts do
use SwissSchema,
schema: [user: MyApp.Accounts.User, token: MyApp.Accounts.Token]
end
Hi @mohammedzeglam-pg,
What role do you think the :token
keyword should play?
Hi @mohammedzeglam-pg,
What role do you think the
:token
keyword should play?
generate function name not all context relay on one schema could context use 2-3 different schema
MyApp.Accuonts.get_user/1
MyApp.Accounts.get_token/1
@mohammedzeglam-pg I see!
Interesting idea. So far, I've considered SwissSchema functions for a single schema only, but if it's going to be used in context modules it might be a good idea to inject functions for multiple schemas.
I'll think more about how the API should look if it will support multiple schemas per context. Thanks for the suggestion!
@mohammedzeglam-pg I see!
Interesting idea. So far, I've considered SwissSchema functions for a single schema only, but if it's going to be used in context modules it might be a good idea to inject functions for multiple schemas.
I'll think more about how the API should look if it will support multiple schemas per context. Thanks for the suggestion!
Maybe run different function as phoenix do with ~:controller~ ~:live_view~ ...etc
and could you consider review #6
I thought about this issue and the scope of this project, and I realized it's not a good idea to extend SwissSchema to such scenarios. SwissSchema should be about having queryable Ecto schemas, not generating functions in context modules.
This should not be implemented, but it's worth a PR to include this decision in FAQ.md
. I'm leaving it open until I get some free time to do it right.
I've been thinking about making SwissSchema able to generate schema functions in other modules than the target schema itself. The use case is to allow it to be used in ctx modules.
Something like that:
This way, SwissSchema could be used to replace generated ctx functions, resulting in cleaner ctx modules.