Replies: 6 comments
-
|
I like what you've desribed here... looks promising. I think this could be related to: #105 - perhaps a refactor to the API can be considered. |
Beta Was this translation helpful? Give feedback.
-
|
After #105, I think it will provide us some compile-time info to work with, i.e. the As such, we'd be able to generate two extra models |
Beta Was this translation helpful? Give feedback.
-
|
Btw... why we cant set an value for primary key with auto_increment during insert? |
Beta Was this translation helpful? Give feedback.
-
|
It is possible to specify the primary key even if a primary key column is auto_increment, but I can't imagine many situations where that'd be useful to anyone. I'm also thinking that the update and insert models can be used with async-graphql under a feature flag in the future, and you typically wouldn't allow the primary key to be set when inserting a new item. But for the async-graphql case, it could just add |
Beta Was this translation helpful? Give feedback.
-
|
Please also note all
Maybe those could be directly excluded for |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @nicoulaj I think you raised a good point not yet considered. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Following up on #97 #94 #96
I have a rough idea:
to annotate the attributes of Entity's Model, where each attribute has three possible 'requirements':
auto_identity(auto generated primary key),required(implied and thus can be omitted) andoptionalfrom there, we can derive two more structs,
InsertModelandUpdateModelFor
InsertModel,auto_identitywill be omitted, and required fields will be wrapped withRequiredValue, which must beSet. Optional fields will be wrapped withActiveValue, which can beSetorUnset.For
UpdateModel,auto_identitywill be wrapped withRequiredValue, while all other fields will be wrapped withActiveValue(thus are optional)change the
InsertandUpdateAPI such that they acceptIntoInsertModelandIntoUpdateModelrespectively.ActiveModelcan still be converted automatically intoInsertModelandUpdateModel, but will panic if the 'requirements' mismatchBeta Was this translation helpful? Give feedback.
All reactions