Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt2y3 committed Sep 11, 2022
1 parent 5af8d94 commit 1d001ab
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 42 deletions.
6 changes: 3 additions & 3 deletions examples/mysql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ version = '0.1.0'
async-graphql = { version = "4.0.10", features = ["decimal", "chrono", "dataloader"] }
async-graphql-poem = { version = "4.0.10" }
async-trait = { version = "0.1.53" }
dotenv = "0.15.0"
heck = { version = "0.4.0" }
itertools = { version = "0.10.3" }
poem = { version = "1.3.29" }
sea-orm = { version = "0.7.0", features = ["sqlx-mysql", "runtime-async-std-native-tls"] }
seaography = { path = "../../", features = [ "with-decimal", "with-chrono" ] } # TODO before production place version here
sea-orm = { version = "^0.9", features = ["sqlx-mysql", "runtime-async-std-native-tls"] }
seaography = { version = "^0.1", path = "../../", features = [ "with-decimal", "with-chrono" ] } # TODO before production place version here
tokio = { version = "1.17.0", features = ["macros", "rt-multi-thread"] }
tracing = { version = "0.1.34" }
tracing-subscriber = { version = "0.3.11" }
dotenv = "0.15.0"

[dev-dependencies]
serde_json = { version = '1.0.82' }
Expand Down
7 changes: 0 additions & 7 deletions examples/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,3 @@
2. `mysql -uroot -h 127.0.0.1 sakila < sakila-schema.sql`
3. `mysql -uroot -h 127.0.0.1 sakila < sakila-data.sql`
4. `cargo run`



### Troubleshooting

#### Different database username and password
Replace `root:root` with `username:password` in src/main.rs
12 changes: 6 additions & 6 deletions examples/mysql/src/entities/customer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ pub enum Relation {
on_delete = "Restrict"
)]
Store,
#[sea_orm(has_many = "super::rental::Entity")]
Rental,
#[sea_orm(has_many = "super::payment::Entity")]
Payment,
#[sea_orm(has_many = "super::rental::Entity")]
Rental,
}

impl Related<super::address::Entity> for Entity {
Expand All @@ -60,15 +60,15 @@ impl Related<super::store::Entity> for Entity {
}
}

impl Related<super::rental::Entity> for Entity {
impl Related<super::payment::Entity> for Entity {
fn to() -> RelationDef {
Relation::Rental.def()
Relation::Payment.def()
}
}

impl Related<super::payment::Entity> for Entity {
impl Related<super::rental::Entity> for Entity {
fn to() -> RelationDef {
Relation::Payment.def()
Relation::Rental.def()
}
}

Expand Down
1 change: 0 additions & 1 deletion examples/mysql/src/entities/film.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub struct Model {
pub title: String,
#[sea_orm(column_type = "Text", nullable)]
pub description: Option<String>,
#[sea_orm(column_type = "Custom(\"YEAR\".to_owned())", nullable)]
pub release_year: Option<String>,
pub language_id: u8,
pub original_language_id: Option<u8>,
Expand Down
12 changes: 6 additions & 6 deletions examples/mysql/src/entities/staff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ pub enum Relation {
on_delete = "Restrict"
)]
Store,
#[sea_orm(has_many = "super::rental::Entity")]
Rental,
#[sea_orm(has_many = "super::payment::Entity")]
Payment,
#[sea_orm(has_many = "super::rental::Entity")]
Rental,
}

impl Related<super::address::Entity> for Entity {
Expand All @@ -62,15 +62,15 @@ impl Related<super::store::Entity> for Entity {
}
}

impl Related<super::rental::Entity> for Entity {
impl Related<super::payment::Entity> for Entity {
fn to() -> RelationDef {
Relation::Rental.def()
Relation::Payment.def()
}
}

impl Related<super::payment::Entity> for Entity {
impl Related<super::rental::Entity> for Entity {
fn to() -> RelationDef {
Relation::Payment.def()
Relation::Rental.def()
}
}

Expand Down
20 changes: 10 additions & 10 deletions examples/mysql/src/query_root.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#[derive(Debug, seaography::macros::QueryRoot)]
#[seaography(entity = "crate::entities::address")]
#[seaography(entity = "crate::entities::film_actor")]
#[seaography(entity = "crate::entities::staff")]
#[seaography(entity = "crate::entities::film_category")]
#[seaography(entity = "crate::entities::store")]
#[seaography(entity = "crate::entities::category")]
#[seaography(entity = "crate::entities::inventory")]
#[seaography(entity = "crate::entities::customer")]
#[seaography(entity = "crate::entities::city")]
#[seaography(entity = "crate::entities::film_actor")]
#[seaography(entity = "crate::entities::category")]
#[seaography(entity = "crate::entities::address")]
#[seaography(entity = "crate::entities::store")]
#[seaography(entity = "crate::entities::film")]
#[seaography(entity = "crate::entities::language")]
#[seaography(entity = "crate::entities::actor")]
#[seaography(entity = "crate::entities::payment")]
#[seaography(entity = "crate::entities::staff")]
#[seaography(entity = "crate::entities::film")]
#[seaography(entity = "crate::entities::rental")]
#[seaography(entity = "crate::entities::country")]
#[seaography(entity = "crate::entities::film_text")]
#[seaography(entity = "crate::entities::inventory")]
#[seaography(entity = "crate::entities::actor")]
#[seaography(entity = "crate::entities::city")]
#[seaography(entity = "crate::entities::country")]
pub struct QueryRoot;
6 changes: 3 additions & 3 deletions examples/sqlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ version = '0.1.0'
async-graphql = { version = "4.0.10", features = ["decimal", "chrono", "dataloader"] }
async-graphql-poem = { version = "4.0.10" }
async-trait = { version = "0.1.53" }
dotenv = "0.15.0"
heck = { version = "0.4.0" }
itertools = { version = "0.10.3" }
poem = { version = "1.3.29" }
sea-orm = { version = "0.7.0", features = ["sqlx-sqlite", "runtime-async-std-native-tls"] }
seaography = { path = "../../", features = [ "with-decimal", "with-chrono" ] } # TODO before production place version here
sea-orm = { version = "^0.9", features = ["sqlx-sqlite", "runtime-async-std-native-tls"] }
seaography = { version = "^0.1", path = "../../", features = [ "with-decimal", "with-chrono" ] } # TODO before production place version here
tokio = { version = "1.17.0", features = ["macros", "rt-multi-thread"] }
tracing = { version = "0.1.34" }
tracing-subscriber = { version = "0.3.11" }
dotenv = "0.15.0"

[dev-dependencies]
serde_json = { version = '1.0.82' }
Expand Down
12 changes: 6 additions & 6 deletions examples/sqlite/src/query_root.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#[derive(Debug, seaography::macros::QueryRoot)]
#[seaography(entity = "crate::entities::customers")]
#[seaography(entity = "crate::entities::invoices")]
#[seaography(entity = "crate::entities::artists")]
#[seaography(entity = "crate::entities::albums")]
#[seaography(entity = "crate::entities::playlist_track")]
#[seaography(entity = "crate::entities::customers")]
#[seaography(entity = "crate::entities::invoice_items")]
#[seaography(entity = "crate::entities::playlists")]
#[seaography(entity = "crate::entities::genres")]
#[seaography(entity = "crate::entities::artists")]
#[seaography(entity = "crate::entities::media_types")]
#[seaography(entity = "crate::entities::playlist_track")]
#[seaography(entity = "crate::entities::invoices")]
#[seaography(entity = "crate::entities::employees")]
#[seaography(entity = "crate::entities::tracks")]
#[seaography(entity = "crate::entities::genres")]
#[seaography(entity = "crate::entities::playlists")]
pub struct QueryRoot;

0 comments on commit 1d001ab

Please sign in to comment.