2020-06-25 18:49:20 +00:00
|
|
|
use anyhow::Result;
|
2020-06-25 10:33:33 +00:00
|
|
|
use diesel::pg::PgConnection;
|
2020-06-25 18:49:20 +00:00
|
|
|
use diesel::RunQueryDsl;
|
2020-06-25 12:42:36 +00:00
|
|
|
|
2020-06-25 10:33:33 +00:00
|
|
|
use crate::schema::pastes;
|
|
|
|
|
2020-06-25 12:42:36 +00:00
|
|
|
use super::entity::Paste;
|
|
|
|
|
2020-06-25 18:49:20 +00:00
|
|
|
pub fn create_paste(paste: &Paste, conn: &PgConnection) -> Result<usize> {
|
|
|
|
let rows = diesel::insert_into(pastes::table)
|
2020-06-25 10:33:33 +00:00
|
|
|
.values(paste)
|
2020-06-25 18:49:20 +00:00
|
|
|
.execute(conn)?;
|
|
|
|
Ok(rows)
|
2020-06-25 10:33:33 +00:00
|
|
|
}
|