-
I was trying to select only a couple of column using
But this fails saying some other column in Data is missing. My guess is that because what all() returns is an Entity, it needs to have all columns in Entity to be returned. This will be impossible for this case since we are only fetching partial columns. Is there a way to make all to return not an Entity but partially set values? like ActiveModel? (where some are set and some are not) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hey @kev0960, you have to select the partial result into a custom struct. https://www.sea-ql.org/SeaORM/docs/advanced-query/custom-select#handling-custom-selects |
Beta Was this translation helpful? Give feedback.
-
For example... #[derive(FromQueryResult)]
struct CustomModel {
some_column: String,
}
let custome_model: Vec<CustomModel> = Data::Entity()
.find()
.select_only(Data::Column::SomeColumn)
.all(&db)
.into_model()
.await? |
Beta Was this translation helpful? Give feedback.
-
Oh Nice. Thank you :) |
Beta Was this translation helpful? Give feedback.
For example...