[wip] paste: Add route to create pastes
Signed-off-by: ATechnoHazard <amolele@gmail.com>
This commit is contained in:
11 files changed
+96
-16
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user