pastes: Add schema and some db ops
Signed-off-by: ATechnoHazard <amolele@gmail.com>
This commit is contained in:
12 files changed
+32
-17
No files matched your search
+2
-1
@@ -1 +1,2 @@
|
||||
pub mod paste;
|
||||
pub mod paste;
|
||||
pub mod users;
|
||||
@@ -0,0 +1,11 @@
|
||||
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> {
|
||||
diesel::insert_into(pastes::table)
|
||||
.values(paste)
|
||||
.execute(conn)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
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
|
||||
}
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,4 @@
|
||||
pub mod diesel;
|
||||
pub mod entity;
|
||||
pub mod repository;
|
||||
pub mod service;
|
||||
Whitespace-only changes.
Whitespace-only changes.
Reference in new issue
Block a user