postgrest-query

Crates.iopostgrest-query
lib.rspostgrest-query
version0.1.0
sourcesrc
created_at2023-12-27 13:50:33.585889
updated_at2023-12-27 13:50:33.585889
descriptionA type-safe query builder-esque experience via PostgREST
homepage
repository
max_upload_size
id1081671
size6,614
Darren Baldwin (DarrenBaldwin07)

documentation

README

postgrest-query

A type-safe query builder-esque experience via PostgREST

Install

cargo add postgrest-query

Usage

use postgrest_query::PostgrestClient;

const URL: &str = "https://org-postgrest-query-demo-inst.data-1.use1.tembo.io/restapi/v1";

#[derive(serde::Serialize, serde::Deserialize)]
struct UserModel {
    id: i32,
    name: String,
    password: String,
}

#[tokio::main]
async fn main() -> Result<(), std::error::Error> {
    let db = PostgrestClient::new(URL);

    let user_query = db.from("users").find_many::<UserModel>().exec().await;
}

TODO

  • Simple Rust -> PostgREST -> Postgres leveraging serde and resembling the Prisma query builder
  • Allow providing custom schemas to enable even better type safety
  • Potentially let consumers provide their own fetcher (defaults to reqwest) for now
  • Compile time query checks (similar to sqlx)
  • Explore potential ports of this to other languages (TypeScript, Python, Go, etc.)
Commit count: 0

cargo fmt