diff --git a/examples/basic/entity/mod.rs b/examples/basic/entity/mod.rs index 4cfff87..d3825f1 100644 --- a/examples/basic/entity/mod.rs +++ b/examples/basic/entity/mod.rs @@ -1,10 +1,12 @@ // setup use sea_orm::sea_query::{ForeignKeyCreateStatement, ColumnDef, TableCreateStatement}; -use sea_orm::{error::*, sea_query, ConnectionTrait, DbConn, ExecResult}; +use sea_orm::{Set, EntityTrait, error::*, sea_query, ConnectionTrait, DbConn, ExecResult}; pub mod comment; pub mod post; pub use comment::Entity as Comment; pub use post::Entity as Post; +use sea_orm::prelude::DateTime; +use sea_orm::prelude::Decimal; // setup async fn create_table(db: &DbConn, stmt: &TableCreateStatement) -> Result { @@ -59,5 +61,30 @@ pub async fn create_post_table(db: &DbConn) -> Result { ) .to_owned(); - create_table(db, &stmt).await + let res = create_table(db, &stmt).await; + + for i in 1..101 { + let row = post::ActiveModel { + title: Set(format!("Test {}", i)), + text: Set("some content".to_string()), + tea_mandatory: Set(post::Tea::EverydayTea), + tea_optional: Set(None), + ..Default::default() + }; + let _res = Post::insert(row).exec(db).await; + } + + for i in 1..101 { + let row = comment::ActiveModel { + comment: Set(format!("Test {}", i)), + user: Set("me@home.com".to_string()), + my_decimal: Set(Decimal::new(105, 0)), + insert_date: Set(DateTime::default()), + is_visible: Set(i%2 == 0), + ..Default::default() + }; + let _res = Comment::insert(row).exec(db).await; + } + + res } diff --git a/examples/basic/main.rs b/examples/basic/main.rs index befa0a4..37daa6c 100644 --- a/examples/basic/main.rs +++ b/examples/basic/main.rs @@ -4,7 +4,6 @@ use actix_admin::prelude::*; use actix_web::{web, App, HttpServer, middleware}; use sea_orm::{ConnectOptions, DatabaseConnection}; use std::time::Duration; - mod entity; use entity::{Post, Comment}; @@ -61,7 +60,7 @@ async fn main() { let conn = sea_orm::Database::connect(opt).await.unwrap(); let _ = entity::create_post_table(&conn).await; - println!("The admin interface will be available at http://localhost:5000/admin/"); + println!("The admin interface is available at http://localhost:5000/admin/"); HttpServer::new(move || { diff --git a/templates/list.html b/templates/list.html index 4519f8f..6d4840c 100644 --- a/templates/list.html +++ b/templates/list.html @@ -133,7 +133,7 @@ -