-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a Trait to organize functions #1
Comments
Ah, neat! I like that you're using Could I ask why you prefer traits though? If it's just a preference, I wouldn't mind if dsync had both options! |
Couple reasons:
|
hey @dessalines, sorry I dropped the ball here -- it's been a busy few weeks. Do you mind creating a PR for this? I think trait-based generation is a good idea moving forward :) |
I pry wouldn't have time for it, with my work on lemmy unfortunately. but somebody else could also take a stab at it. |
The issue I see with trying this is that a trait can't cover instances where there are multiple primary keys at least not without some major refactoring of the codebase (passing a collection (that can have an arbitrary number of elements each with different data types, which I'm not sure exists for rust) instead of having a parameter per primary key) |
on second thought, using macros could work as macros can be variadic |
Hey, one of the creators of lemmy here, this looks like a really interesting project that could help us. We have a lot of tables, and generating a lot of the simpler Crud-type functions in code would make this really useful.
Instead of
pub struct UpdateTodo
and exporting that, I highly recommend creating a trait. Here's what we do in our code:Then your generated code would be:
And people could easily import Crud to get all the functions.
The text was updated successfully, but these errors were encountered: