Skip to content

Instantly share code, notes, and snippets.

@trimoq
Last active October 21, 2019 11:12
Show Gist options
  • Save trimoq/455ddf31149d668a94a5e0df9daa7887 to your computer and use it in GitHub Desktop.
Save trimoq/455ddf31149d668a94a5e0df9daa7887 to your computer and use it in GitHub Desktop.
pub fn insert(con: &DbCon, new_stay: NewStay) -> Result<Stay, Error> {
diesel::insert_into(stay::table)
.values(&new_stay)
.get_result(&**conn)
}
pub fn get_all_for_user(con: &DbCon, user: ApiUser) -> Vec<Stay> {
Stay::belonging_to(&user)
.load::<Stay>(&**conn)
.unwrap() // this is quite bad but let's ignore it for the example
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment