Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matthunz/typed-sql
https://github.com/matthunz/typed-sql
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/matthunz/typed-sql
- Owner: matthunz
- License: mit
- Created: 2021-05-20T02:34:54.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-15T19:17:25.000Z (over 1 year ago)
- Last Synced: 2024-04-29T14:22:39.974Z (7 months ago)
- Language: Rust
- Size: 74.2 KB
- Stars: 194
- Watchers: 8
- Forks: 13
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# typed-sql
[![Latest Version](https://img.shields.io/crates/v/typed-sql.svg)](https://crates.io/crates/typed-sql)
[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/typed-sql)
![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)```rust
use typed_sql::{Query, Table, ToSql};#[derive(Table)]
struct User {
id: i64,
name: String
}let stmt = User::table()
.select()
.filter(|user| user.id.neq(6).and(user.id.gt(3)))
.group_by(|user| user.name)
.order_by(|user| user.name.then(user.id.ascending()))
.limit(5);assert_eq!(
stmt.to_sql(),
"SELECT * FROM users \
WHERE users.id != 6 AND users.id > 3 \
GROUP BY users.name \
ORDER BY users.name,users.id ASC \
LIMIT 5;"
);
```