Should we divide data model and layout definition? #4343
bbtgnn
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Good morning :)
First of all, let me say that I absolutely love Payload: we're currently moving our project to Payload because of the high level of flexibility it offers. Keep up the good work!
Here's my idea: while working on creating collections, it felt a bit awkward to me to mix the data model fields with the layout fields – it felt like a significant violation of the separation of concerns principle.
In my opinion, it would be better to separate the two (like, a
CollectionConfig
and aCollectionUIConfig
). This separation would allow one to focus on the data model and then also freely change the layout without worrying about breaking the data model.As a side note, I also had this idea on how to enforce type safety when moving information from the collection config to the UI config.
If we do something like this:
you can see that
FieldsNames
correctly has the type"name" | "age"
. Andsatisfies
enforces type safety on theFields
type.This approach ensures that this type can be easily used in the definition of the UI config.
Let me know what you think!
Beta Was this translation helpful? Give feedback.
All reactions