-
let query_builder = model::comments::Entity::find()
.select_only()
.column(model::comments::Column::Id)
.column(model::comments::Column::Content)
.column(model::comments::Column::CreateTime)
.column(model::comments::Column::UserId)
.column(model::comments::Column::TargetId)
.column(model::comments::Column::TargetType)
.filter(condition)
.pagination(current_page, page_size);
let reply_to_user_alias = Alias::new("reply_to_user");
let list: Vec<CommentListItem> = query_builder
.column_as(model::user::Column::NickName, "user_nickname")
.column_as(model::user::Column::Id, "user_id")
.column_as(model::user::Column::Avatar, "user_avatar")
.join(
sea_orm::JoinType::LeftJoin,
model::comments::Relation::User.def(),
)
.join_as(
sea_orm::JoinType::LeftJoin,
model::comments::Relation::ReplyToUser.def(),
reply_to_user_alias.clone(),
)
.column_as(model::user::Column::NickName, "user_nickname")
.column_as(model::user::Column::NickName, "reply_to_user_nickname")
.column_as(model::user::Column::Id, "reply_to_user_id")
.into_model()
.all(db_conn)
.await?;in upper there will join user twice from btw: there are too many disscuss about join mutiple, if there have a well documented by official i think it's good for architecture evolution |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
This software is excellent, but it's been evolving for several years now. I imagine the maintainers have probably come up with better ideas than the original design during the development process. I'm wondering if there's any plan to gradually refactor the project over time. If the APIs become more convenient to use, I’d be happy to follow along and upgrade incrementally. |
Beta Was this translation helpful? Give feedback.
-
|
You didn't specify which join the following columns come from. .column_as(
Expr::col((reply_to_user_alias.clone(), model::user::Column::NickName)),
"reply_to_user_nickname"
) |
Beta Was this translation helpful? Give feedback.
You didn't specify which join the following columns come from.