fix(db): Explicitly order posts in a thread
This commit is contained in:
parent
9bc5bbff54
commit
c5cf911a07
1 changed files with 5 additions and 2 deletions
|
@ -60,12 +60,15 @@ impl Handler<GetThread> for DbExecutor {
|
||||||
|
|
||||||
fn handle(&mut self, msg: GetThread, _: &mut Self::Context) -> Self::Result {
|
fn handle(&mut self, msg: GetThread, _: &mut Self::Context) -> Self::Result {
|
||||||
use schema::threads::dsl::*;
|
use schema::threads::dsl::*;
|
||||||
|
use schema::posts::dsl::id;
|
||||||
|
|
||||||
let conn = self.0.get()?;
|
let conn = self.0.get()?;
|
||||||
let thread_result: Thread = threads
|
let thread_result: Thread = threads
|
||||||
.find(msg.0).first(&conn)?;
|
.find(msg.0).first(&conn)?;
|
||||||
|
|
||||||
let post_list = Post::belonging_to(&thread_result).load::<Post>(&conn)?;
|
let post_list = Post::belonging_to(&thread_result)
|
||||||
|
.order_by(id.asc())
|
||||||
|
.load::<Post>(&conn)?;
|
||||||
|
|
||||||
Ok((thread_result, post_list))
|
Ok((thread_result, post_list))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue