A library derived as a slim version of sqlx-crud to provide metadata about the entity it marks, design to only provide the building blocks for you to build your own queries.
Add to your dependencies:
toml
sqlx-meta = "0.1.0"
And mark your entity with SqlxMeta
:
```rust
pub struct File {
pub id: Option
Build your own query (prefer lazy_static
when it doesn't really change):
```rust lazystatic! { static ref INSERTSQL: String = { let cols = &File::columns()[1..];
let holders = (0..cols.len()).map(|_| "?").collect::<Vec<_>>().join(", ");
let excludes = cols
.iter()
.map(|c| format!("'{}'=excluded.'{}'", c, c))
.collect::<Vec<_>>()
.join(",");
// ..
// ..
```
Use the update_binds
or insert_binds
methods to save up typing:
rust
use sqlx_meta::{Binds, Schema};
f.update_binds(q).fetch_optional(&mut conn).await?;