-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from longsleep-io/longsleep-optional-functions
Add --no-crud option to skip generating CRUD functions
- Loading branch information
Showing
9 changed files
with
110 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod todos; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* This file is generated and managed by dsync */ | ||
|
||
use crate::diesel::*; | ||
use crate::schema::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset, Selectable)] | ||
#[diesel(table_name=todos, primary_key(id))] | ||
pub struct Todo { | ||
pub id: i32, | ||
pub unsigned: u32, | ||
pub text: String, | ||
pub completed: bool, | ||
pub created_at: chrono::DateTime<chrono::Utc>, | ||
pub updated_at: chrono::DateTime<chrono::Utc>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset)] | ||
#[diesel(table_name=todos)] | ||
pub struct CreateTodo { | ||
pub unsigned: u32, | ||
pub text: String, | ||
pub completed: bool, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset)] | ||
#[diesel(table_name=todos)] | ||
pub struct UpdateTodo { | ||
pub unsigned: Option<u32>, | ||
pub text: Option<String>, | ||
pub completed: Option<bool>, | ||
pub created_at: Option<chrono::DateTime<chrono::Utc>>, | ||
pub updated_at: Option<chrono::DateTime<chrono::Utc>>, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub use generated::*; | ||
pub mod generated; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
diesel::table! { | ||
todos (id) { | ||
id -> Int4, | ||
unsigned -> Unsigned<Integer>, | ||
text -> Text, | ||
completed -> Bool, | ||
created_at -> Timestamptz, | ||
updated_at -> Timestamptz, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
|
||
cd $SCRIPT_DIR | ||
|
||
cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection<diesel::r2d2::ConnectionManager<diesel::PgConnection>>" --no-crud |