Replies: 4 comments
-
That's a very interesting idea, what are some ready-to-use strategies you have in mind? |
Beta Was this translation helpful? Give feedback.
-
Thanks. First of all, from my previous experience using Java ORM frameworks, UUID would be a kind (built-in in Hibernate) that may not be commonly used but can still be used in simple scenarios, although it is not recommended to use UUID as the primary key for tables. Secondly, another generation strategy is similar to Facebook's Snowflake ID (built-in in MybatisPlus). I saw a good library for this in Rust: |
Beta Was this translation helpful? Give feedback.
-
Thank you for your suggestions. They all seemed very interesting. Without Along with #1956 the problem is whether we add an default type parameter to entity: trait EntityTrait<B: EntityBehaviour = DefaultEntityBehaviour> Or attach it to trait EntityTrait {
...
type A: ActiveModelBehaviour;
} The latter would require a breaking change, but I feel like it's a cleaner solution for the long term. |
Beta Was this translation helpful? Give feedback.
-
I also think it would be better to attach it to |
Beta Was this translation helpful? Give feedback.
-
Motivation
If I don't use the auto-increment method of the database's primary key, then I have to generate the primary key automatically when inserting data in the program. However, this is a highly repetitive and irrelevant task. It would be ideal if the framework could handle it instead.
Proposed Solutions
We can set a primary key generation strategy for orm framwork, or the framework itself provides several ready-to-use strategies for users to choose directly.
Current Workarounds
Manually generate a primary key, then set it to ActiveModel and save it to the database.
Beta Was this translation helpful? Give feedback.
All reactions