The backend of a gist server written in Rust
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mod.rs 454B

12345678910111213141516171819
  1. use diesel::pg::PgConnection as PGC;
  2. use diesel::prelude::*;
  3. use crate::schema::gists;
  4. #[derive(Queryable, AsChangeset, Serialize, Deserialize)]
  5. pub struct Gist {
  6. pub id: i32,
  7. pub title: String,
  8. pub body: String,
  9. }
  10. pub fn all(connection: &PGC) -> QueryResult<Vec<Gist>> {
  11. gists::table.load::<Gist>(&*connection)
  12. }
  13. pub fn get(connection: &PGC, id: i32) -> QueryResult<Gist> {
  14. gists::table.find(id).get_result::<Gist>(connection)
  15. }