Skip to content

Commit

Permalink
sea-orm update for ci
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn committed Sep 20, 2022
1 parent 5f1eeb8 commit 9524d95
Show file tree
Hide file tree
Showing 23 changed files with 11 additions and 47 deletions.
11 changes: 4 additions & 7 deletions examples/seaorm/Cargo.toml → examples/db-sea-orm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
[package]
name = "sea-orm-salvo-example"
name = "example-db-sea-orm"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[workspace]
members = [".", "entity", "migration"]
publish = false

[dependencies]
tokio = { version = "1.21.1", features = ["macros", "rt-multi-thread"] }
Expand All @@ -15,12 +12,12 @@ tracing-subscriber = { version = "0.3.15", features = ["env-filter"] }
serde = { version = "1.0.144", features = ["derive"] }
tera = "1.17.1"
dotenv = "0.15"
entity = { path = "entity" }
migration = { path = "migration" }
sea-orm = { version = "0.9.2", features = [
"debug-print",
"runtime-tokio-native-tls",
"sqlx-sqlite",
# "sqlx-postgres",
# "sqlx-mysql",
] }
async-std = { version = "^1", features = ["attributes", "tokio1"] }
sea-orm-migration = "0.9.2"
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

3. Execute `cargo run` to start the server

4. Visit [localhost:8000](http://localhost:8000) in browser after seeing the `server started` line
4. Visit [localhost:7878](http://localhost:7878) in browser after seeing the `server started` line
File renamed without changes
File renamed without changes.
File renamed without changes.
11 changes: 6 additions & 5 deletions examples/seaorm/src/main.rs → examples/db-sea-orm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ use salvo::writer::Text;
use sea_orm::{entity::*, query::*, DatabaseConnection};
use tera::Tera;

mod entity;
mod migration;

const DEFAULT_POSTS_PER_PAGE: u64 = 5;
type Result<T> = std::result::Result<T, StatusError>;

Expand Down Expand Up @@ -156,15 +159,13 @@ async fn main() {
std::env::set_var("RUST_LOG", "debug");
tracing_subscriber::fmt::init();

// get env vars
dotenv::dotenv().ok();
let db_url = env::var("DATABASE_URL").expect("DATABASE_URL is not set in .env file");
let db_url = "sqlite::memory:";
let host = env::var("HOST").unwrap_or("0.0.0.0".to_owned());
let port = env::var("PORT").unwrap_or("8080".to_owned());
let port = env::var("PORT").unwrap_or("7878".to_owned());
let server_url = format!("{}:{}", host, port);

// create post table if not exists
let conn = sea_orm::Database::connect(&db_url).await.unwrap();
let conn = sea_orm::Database::connect(db_url).await.unwrap();
Migrator::up(&conn, None).await.unwrap();
let templates = Tera::new(concat!(env!("CARGO_MANIFEST_DIR"), "/templates/**/*")).unwrap();
let state = AppState { templates, conn };
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions examples/seaorm/.env

This file was deleted.

3 changes: 0 additions & 3 deletions examples/seaorm/.gitignore

This file was deleted.

14 changes: 0 additions & 14 deletions examples/seaorm/entity/Cargo.toml

This file was deleted.

13 changes: 0 additions & 13 deletions examples/seaorm/migration/Cargo.toml

This file was deleted.

0 comments on commit 9524d95

Please sign in to comment.