[wip] paste: Add route to create pastes

Signed-off-by: ATechnoHazard <amolele@gmail.com>
This commit is contained in:
sphericalkat committed 2020-06-25 18:12:36 +05:30
1 parent 0556a03396
commit 0e5abac774
11 files changed
+96 -16

No files matched your search

+6 -4
View File
@@ -1,10 +1,12 @@
use diesel::{RunQueryDsl};
use diesel::pg::PgConnection;
use diesel::result::Error;
use super::entity::Paste;
use crate::schema::pastes;
use diesel::{RunQueryDsl, QueryResult};
pub fn create(paste: &Paste, conn: &PgConnection) -> Result<usize, Error> {
use crate::schema::pastes;
use super::entity::Paste;
pub fn create_paste(paste: &Paste, conn: &PgConnection) -> Result<usize, Error> {
diesel::insert_into(pastes::table)
.values(paste)
.execute(conn)
+4 -4
View File
@@ -3,8 +3,8 @@ use crate::schema::pastes;
#[table_name="pastes"]
#[derive(AsChangeset, Serialize, Deserialize, Queryable, Insertable)]
pub struct Paste {
id: String,
belongs_to: String,
is_url: bool,
content: String
pub id: Option<String>,
pub belongs_to: String,
pub is_url: bool,
pub content: String
}