MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / get_post_by_id

Method get_post_by_id

examples/tonic_example/api/src/lib.rs:99–115  ·  view source on GitHub ↗
(&self, request: Request<PostId>)

Source from the content-addressed store, hash-verified

97 }
98
99 async fn get_post_by_id(&self, request: Request<PostId>) -> Result<Response<Post>, Status> {
100 let conn = &self.connection;
101 let id = request.into_inner().id;
102
103 if let Some(post) = Query::find_post_by_id(conn, id).await.ok().flatten() {
104 Ok(Response::new(Post {
105 id,
106 title: post.title,
107 content: post.text,
108 }))
109 } else {
110 Err(Status::new(
111 tonic::Code::Aborted,
112 "Could not find post with id ".to_owned() + &id.to_string(),
113 ))
114 }
115 }
116}
117
118#[tokio::main]

Callers

nothing calls this directly

Calls 2

into_innerMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected