-
would sea orm support get column by string,this case often happen in table sort or filt something,current if i want implement sort func i should get :1. is ascend or descend 2.which column will be affect. i need write every query builder as : fn get_column_type_by_name(column_name: &str) -> Option<Type> {
let entity = Model::Entity;
let column_type = match column_name {
"id" => Some(Column::Id),
"name" => Some(Column::Name),
"email" => Some(Column::Email),
_ => None,
};
column_type
}
fn main() {
if let Some(column_type) = get_column_type_by_name("name") {
println!("get column is: {:?}", column_type);
}
} if there have some function to drop in string and return a col type would be help full expect fn main() {
if let Some(column_type) = entity:Column:get_column_by_name("name") { // direct return Some Column
println!("get column is: {:?}", column_type);
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
tyt2y3
May 9, 2024
Replies: 1 comment 1 reply
-
Here it is! Lines 513 to 537 in aa626fc |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
tyt2y3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here it is!
sea-orm/src/entity/column.rs
Lines 513 to 537 in aa626fc