Skip to main content

🐚 SeaORM X is built on top of SeaORM with support for SQL Server


Async

Relying on SQLx and tiberius, SeaORM X is a new library with async support from day 1.

Dynamic

Built upon SeaQuery X, SeaORM X allows you to build complex dynamic queries.

Testable

Use mock connections and/or SQLite to write tests for your application logic.

Service Oriented

Quickly build services that join, filter, sort and paginate data in REST, GraphQL and gRPC APIs.

A quick taste of SeaORM X

// A table create statement
let table = Table::create()
.table(Glyph::Table)
.col(ColumnDef::new(Glyph::Id).integer().not_null().auto_increment().primary_key())
.col(ColumnDef::new(Glyph::Aspect).integer().not_null())
.col(ColumnDef::new(Glyph::Image).string().not_null())
.foreign_key(
ForeignKey::create()
.name("FK_2e303c3a712662f1fc2a4d0aad6")
.from(Glyph::Table, Glyph::Id)
.to(CharGlyph::Table, CharGlyph::GlyphId)
.on_delete(ForeignKeyAction::Cascade)
.on_update(ForeignKeyAction::Cascade)
)
.to_owned();
assert_eq!(
table.to_string(MsSqlQueryBuilder),
[
r#"CREATE TABLE [glyph] ("#,
r#"[id] int NOT NULL IDENTITY PRIMARY KEY,"#,
r#"[aspect] int NOT NULL,"#,
r#"[image] nvarchar(255) NOT NULL,"#,
r#"CONSTRAINT [FK_2e303c3a712662f1fc2a4d0aad6]"#,
r#"FOREIGN KEY ([id]) REFERENCES [character_glyph] ([glyph_id])"#,
r#"ON DELETE CASCADE ON UPDATE CASCADE"#,
r#")"#,
].join(" ")
);
// A prepared select statement
assert_eq!(
Query::select()
.column(Glyph::Image)
.from(Glyph::Table)
.and_where(Expr::col(Glyph::Image).like("A"))
.and_where(Expr::col(Glyph::Id).is_in([1, 2, 3]))
.build(MsSqlQueryBuilder),
(
"SELECT [image] FROM [glyph] WHERE [image] LIKE @P1 AND [id] IN (@P2, @P3, @P4)"
.to_owned(),
Values(vec![
Value::String(Some(Box::new("A".to_owned()))),
Value::Int(Some(1)),
Value::Int(Some(2)),
Value::Int(Some(3))
])
)
);
// A raw select statement
assert_eq!(
Query::select()
.column(Glyph::Id)
.from(Glyph::Table)
.cond_where(
Cond::any()
.add(
Cond::all()
.add(Expr::col(Glyph::Aspect).is_null())
.add(Expr::col(Glyph::Image).is_null())
)
.add(
Cond::all()
.add(Expr::col(Glyph::Aspect).is_in([3, 4]))
.add(Expr::col(Glyph::Image).like("A%"))
)
)
.to_string(MsSqlQueryBuilder),
[
r#"SELECT [id] FROM [glyph]"#,
r#"WHERE ([aspect] IS NULL AND [image] IS NULL)"#,
r#"OR ([aspect] IN (3, 4) AND [image] LIKE 'A%')"#,
]
.join(" ")
);

Meet Terres, our official mascot

A friend of Ferris, Terres the hermit crab is a member of the Rustacean family.