From 1d001ab91cea35545893b7f5fcd2ebe3c7313617 Mon Sep 17 00:00:00 2001 From: Chris Tsang Date: Sun, 11 Sep 2022 22:16:12 +0800 Subject: [PATCH] Update examples --- examples/mysql/Cargo.toml | 6 +++--- examples/mysql/README.md | 7 ------- examples/mysql/src/entities/customer.rs | 12 ++++++------ examples/mysql/src/entities/film.rs | 1 - examples/mysql/src/entities/staff.rs | 12 ++++++------ examples/mysql/src/query_root.rs | 20 ++++++++++---------- examples/sqlite/Cargo.toml | 6 +++--- examples/sqlite/src/query_root.rs | 12 ++++++------ 8 files changed, 34 insertions(+), 42 deletions(-) diff --git a/examples/mysql/Cargo.toml b/examples/mysql/Cargo.toml index 1adea739..102c6fe4 100644 --- a/examples/mysql/Cargo.toml +++ b/examples/mysql/Cargo.toml @@ -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' } diff --git a/examples/mysql/README.md b/examples/mysql/README.md index 05bcf672..0c964ba3 100644 --- a/examples/mysql/README.md +++ b/examples/mysql/README.md @@ -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 \ No newline at end of file diff --git a/examples/mysql/src/entities/customer.rs b/examples/mysql/src/entities/customer.rs index fbe40a60..920dfe3b 100644 --- a/examples/mysql/src/entities/customer.rs +++ b/examples/mysql/src/entities/customer.rs @@ -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 for Entity { @@ -60,15 +60,15 @@ impl Related for Entity { } } -impl Related for Entity { +impl Related for Entity { fn to() -> RelationDef { - Relation::Rental.def() + Relation::Payment.def() } } -impl Related for Entity { +impl Related for Entity { fn to() -> RelationDef { - Relation::Payment.def() + Relation::Rental.def() } } diff --git a/examples/mysql/src/entities/film.rs b/examples/mysql/src/entities/film.rs index 61579eb2..6d13d4f4 100644 --- a/examples/mysql/src/entities/film.rs +++ b/examples/mysql/src/entities/film.rs @@ -18,7 +18,6 @@ pub struct Model { pub title: String, #[sea_orm(column_type = "Text", nullable)] pub description: Option, - #[sea_orm(column_type = "Custom(\"YEAR\".to_owned())", nullable)] pub release_year: Option, pub language_id: u8, pub original_language_id: Option, diff --git a/examples/mysql/src/entities/staff.rs b/examples/mysql/src/entities/staff.rs index 08531a0f..36245d6f 100644 --- a/examples/mysql/src/entities/staff.rs +++ b/examples/mysql/src/entities/staff.rs @@ -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 for Entity { @@ -62,15 +62,15 @@ impl Related for Entity { } } -impl Related for Entity { +impl Related for Entity { fn to() -> RelationDef { - Relation::Rental.def() + Relation::Payment.def() } } -impl Related for Entity { +impl Related for Entity { fn to() -> RelationDef { - Relation::Payment.def() + Relation::Rental.def() } } diff --git a/examples/mysql/src/query_root.rs b/examples/mysql/src/query_root.rs index a394bd89..b755a2b7 100644 --- a/examples/mysql/src/query_root.rs +++ b/examples/mysql/src/query_root.rs @@ -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; diff --git a/examples/sqlite/Cargo.toml b/examples/sqlite/Cargo.toml index 256b4fe6..f1228985 100644 --- a/examples/sqlite/Cargo.toml +++ b/examples/sqlite/Cargo.toml @@ -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' } diff --git a/examples/sqlite/src/query_root.rs b/examples/sqlite/src/query_root.rs index fc9ac1b0..7ca41e71 100644 --- a/examples/sqlite/src/query_root.rs +++ b/examples/sqlite/src/query_root.rs @@ -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;