postgrest-rs 🦀
PostgREST client-side library (Rust edition). This library aims to reach feature parity with postgrest-js in providing an "ORM-like" RESTful interface.
Usage
Generally, you want to instantiate a Postgrest struct, optionally switch
schema with .schema(), call .from() (or .rpc() for stored procedures), do
some filtering and stuff, and then call .execute().
Simple example:
use Postgrest;
let client = new;
let resp = client
.from
.select
.execute
.await?;
let body = resp
.text
.await?;
Using filters:
let resp = client
.from
.eq
.gte
.select
.execute
.await?;
Updating a table:
let resp = client
.from
.eq
.update
.execute
.await?;
Executing stored procedures:
let resp = client
.rpc
.execute
.await?;
Not enough filters:
let resp = client
.from
.eq
.gt
.lt
.gte
.lte
.like
.ilike
.is
.in_
.neq
.fts
.plfts
.phfts
.wfts
.cs
.cd
.ov
.sl
.sr
.nxl
.nxr
.adj
.select
.execute
.await?;
More examples incoming!
Limitations
This library doesn't show the full extent of PostgREST, and definitely doesn't replace the need to learn PostgREST. Some known limitations are:
- Doesn't support
not,and, andorin filtering - Many inputs are unsanitized (multi-column select, insert/update body, etc.)
- Counting (with HEAD verb)
- Resource embedding (embedded filters, etc.)
That said, if there are any features you want in, feel free to create an issue!
Contributing
- Fork the repo on GitHub
- Clone the project to your own machine
- Commit changes to your own branch
- Push your work back up to your fork
- Submit a Pull request so that we can review your changes and merge
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as below, without any additional terms or conditions.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.