2022-08-05 08:04:32 +08:00
2022-08-04 19:06:18 +08:00
2022-08-04 19:06:18 +08:00
2022-08-04 17:43:33 +08:00
2022-08-04 19:06:18 +08:00
2022-08-04 17:43:33 +08:00
2022-08-04 17:43:33 +08:00
2022-08-04 17:43:33 +08:00
2022-08-05 08:04:32 +08:00

Rust Template Project for Development with Actix-Web and SeaORM

A lot of Thanks to these projects

This project template is made of:

  • Rust
  • actix-web: Async web framework for rust
  • SeaORM: async ORM for integrating a Rust code base with relational databases

And I won't reach this without the help of:

  • sqlx
  • askama
  • clap
  • clap_complete
  • serde
  • env_logger
  • log

Project strucutre

Start from here

Run the server

Simply use cargo to run the project

Package into container

The template provides a simple Dockerfile and script to build container image.

Development

Define a new model

  1. Install sea-orm-cli first
cargo install sea-orm-cli
  1. Define migration in migrations
#[derive(Iden)]
pub enum User { // Identifiers for User table
    Table, // Table Identifier
    Id, // Id Column Identifier
    Name, // Name Column Identifier
    Password, // Password Column Identifier
}

impl MigrationName for Migration {
    fn name(&self) -> &str {
        "m20220804_000001_create_user_table" // A migration name `m$(date +%Y%m%d)_8digitno_desc`
    }
}

#[async_trait::async_trait]
impl MigrationTrait for Migration {
    async fn up(&self, manager: & sea_orm_migration::SchemaManager) ->  Result<(),sea_orm::DbErr> {
        manager.create_table(
            Table::create()
                .table(User::Table) // Table
                .col(ColumnDef::new(User::Id).integer().primary_key().auto_increment().not_null()) // And each col
                .col(ColumnDef::new(User::Name).string().unique_key().not_null())
                .col(ColumnDef::new(User::Password).string().not_null())
                .to_owned()
        ).await
    }

    async fn down(&self, manager: & sea_orm_migration::SchemaManager) ->  Result<(),sea_orm::DbErr> {
        manager.drop_table(Table::drop().table(User::Table).to_owned()).await
    }
}
  1. Add migration into migrator

TODO

  1. Run migrator

TODO

  1. Generate models

TODO

Roadmap

  • Web
  • ORM
  • Packaging
  • React
Description
No description provided
Readme 67 KiB
Languages
Rust 93.2%
Dockerfile 4.2%
Shell 2.6%