hhstore / blog

My Tech Blog: about Mojo / Rust / Golang / Python / Kotlin / Flutter / VueJS / Blockchain etc.
https://github.com/hhstore/blog/issues
276 stars 22 forks source link

Rust: ORM - SeaORM #368

Open hhstore opened 2 years ago

hhstore commented 2 years ago

related:

hhstore commented 2 years ago

Rust ORM - SeaORM 教程:

使用体验:

关于作者:

特性:

文档:

示例:

Debug 调试日志工具:

Cli 工具:

自动生成 db model(entity) 数据结构.


# Generate entity files of database `bakery` to `entity/src`
$ sea-orm-cli generate entity \
    -u sql://sea:sea@localhost/bakery \
    -o entity/src

自带 migration 工具.

# Setup the migration directory in `./migration`
$ sea-orm-cli migrate init
Initializing migration directory...
Creating file `./migration/src/lib.rs`
Creating file `./migration/src/m20220101_000001_create_table.rs`
Creating file `./migration/src/main.rs`
Creating file `./migration/Cargo.toml`
Creating file `./migration/README.md`
Done!

# If you want to setup the migration directory in else where
$ sea-orm-cli migrate init -d ./other/migration/dir

$ sea-orm-cli migrate COMMAND

$ sea-orm-cli migrate COMMAND -d ./other/migration/dir

参考:

hhstore commented 2 years ago

SeaORM 核心功能:

DB+Table 操作:

CRUD:

关系表示:

事务机制:

测试:

hhstore commented 2 years ago

踩坑记录:

sea-orm 与 axum route 的冲突 & 解决.

hhstore commented 2 years ago

1

hhstore commented 2 years ago

1

hhstore commented 2 years ago

1

hhstore commented 2 years ago

1