Replies: 8 comments
-
Since use strum::EnumIter;
use sea_query::{Iden, Query};
#[derive(Iden, EnumIter)]
enum MyModel {
Id,
MyColumn,
/* etc */
}
Query::select().columns(MyModel::iter()) |
Beta Was this translation helpful? Give feedback.
-
Will use it, still think it would be a good idea to have the |
Beta Was this translation helpful? Give feedback.
-
An Iden implementation on a struct will only give a single column reference. If you wish to associate multiple iden's to a single struct you're still going to need an enum and associate it to the struct. If you want this to all be automatically derived, you're looking for an ORM. |
Beta Was this translation helpful? Give feedback.
-
Right that make sense. I usually prefer query builders. The Iden on struct could generate Iden for all fields too or generate a DSL but I guess that would be more for an ORM. |
Beta Was this translation helpful? Give feedback.
-
I think thats also in the ORM territory, since you still need to generate a list of something that implements iden. Since iden cannot give a stringified list because the query builder quotes the output of that string. You could make that it returns a list of |
Beta Was this translation helpful? Give feedback.
-
@Progdrasil thank you for helping out |
Beta Was this translation helpful? Give feedback.
-
@tyt2y3 I am most likely going to continue using the query builder because I have complex queries with a lot of conditionals and joins that are usually very hard to express in an ORM (thus our switch from diesel to sea-query). |
Beta Was this translation helpful? Give feedback.
-
Now that SeaORM is 'public', please take a look and see if it helps! |
Beta Was this translation helpful? Give feedback.
-
Hi!
I could not find an easy way to specify all columns (but not star).
Maybe Iden could implement an
all()
function that returns a vec?It would look like:
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions