Brendonovich / prisma-client-rust

Type-safe database access for Rust
https://prisma.brendonovich.dev
Apache License 2.0
1.84k stars 108 forks source link

Traits for making extensible queries #232

Closed Brendonovich closed 1 year ago

Brendonovich commented 1 year ago

Traits like Where, Order etc for making wrapper functions that apply preset settings.

tingfeng-key commented 1 year ago

Can Query Traits be used outside the library? Or an example of using Query Traits

For example, I have a query structure:

struct UserQuery {
  name: Option<String>,
  sex: Option<i32>,
}

If the name is not none, add the name to the where condition, and the sex is the same. Is there any way to handle to where conveniently?

Brendonovich commented 1 year ago

Not currently, though that's a kinda similar idea to the partial_unchecked! macro. I've got a couple of ideas but I'm not quite sure.