Skip to content

Commit 0082ab2

Browse files
authored
docs: flesh out API docs
1 parent 7ca24cf commit 0082ab2

File tree

3 files changed

+333
-46
lines changed

3 files changed

+333
-46
lines changed

README.md

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1-
# postgrest-rs 🦀
1+
# postgrest-rs
22

3-
[![build](https://github.com/supabase/postgrest-rs/workflows/CI/badge.svg)](https://github.com/supabase/postgrest-rs/actions?query=branch%3Amaster)
3+
[![Build](https://github.com/supabase/postgrest-rs/workflows/CI/badge.svg)](https://github.com/supabase/postgrest-rs/actions?query=branch%3Amaster)
4+
[![Crate](https://img.shields.io/crates/v/postgrest.svg)](https://crates.io/crates/postgrest)
5+
[![API](https://docs.rs/postgrest/badge.svg)](https://docs.rs/postgrest)
46
[![License: Apache-2.0 OR MIT](https://img.shields.io/crates/l/postgrest.svg)](#license)
57

6-
[PostgREST](https://postgrest.org/) client-side library (Rust edition). This library aims to reach feature parity with [postgrest-js](https://github.com/supabase/postgrest-js) in providing an "ORM-like" RESTful interface.
8+
[PostgREST](https://postgrest.org/) client-side library 🦀. This library provides an ORM interface to PostgREST.
79

810
## Usage
911

10-
Generally, you want to instantiate a `Postgrest` struct, optionally switch
11-
schema with `.schema()`, call `.from()` (or `.rpc()` for stored procedures), do
12-
some filtering and stuff, and then call `.execute()`.
12+
Add this to your `Cargo.toml`:
13+
14+
```toml
15+
[dependencies]
16+
postgrest = "1.0"
17+
```
1318

1419
Simple example:
1520

1621
```rust
1722
use postgrest::Postgrest;
1823

19-
let client = Postgrest::new("https://your-postgrest-endpoint");
24+
let client = Postgrest::new("https://your.postgrest.endpoint");
2025
let resp = client
2126
.from("your_table")
2227
.select("*")
@@ -64,54 +69,42 @@ _Not enough filters_:
6469
```rust
6570
let resp = client
6671
.from("countries")
67-
.eq("name", "New Zealand")
72+
.eq("name", "New Zealand") // You can filter for equality...
6873
.gt("id", "20")
6974
.lt("id", "20")
7075
.gte("id", "20")
7176
.lte("id", "20")
72-
.like("name", "%United%")
77+
.like("name", "%United%") // ...do pattern matching...
7378
.ilike("name", "%United%")
7479
.is("name", "null")
7580
.in_("name", vec!["China", "France"])
7681
.neq("name", "China")
77-
.fts("phrase", "The Fat Cats", Some("english"))
82+
.fts("phrase", "The Fat Cats", Some("english")) // ...do full text search...
7883
.plfts("phrase", "The Fat Cats", None)
7984
.phfts("phrase", "The Fat Cats", Some("english"))
8085
.wfts("phrase", "The Fat Cats", None)
8186
.cs("countries", "(10,20)")
8287
.cd("countries", "(10,20)")
8388
.ov("population_range", (100, 500))
84-
.sl("population_range", (100, 500))
85-
.sr("population_range", (100, 500))
86-
.nxl("population_range", (100, 500))
89+
.sl("population_range", (100, 500)) // ...and range operations!
90+
.sr("population_range", (100, 500)) // Find out more about the filters at:
91+
.nxl("population_range", (100, 500)) // https://postgrest.org/en/stable/api.html#operators
8792
.nxr("population_range", (100, 500))
8893
.adj("population_range", (100, 500))
8994
.select("*")
9095
.execute()
9196
.await?;
9297
```
9398

94-
More examples incoming!
95-
96-
## Limitations
97-
98-
This library doesn't show the full extent of PostgREST, and definitely doesn't
99-
replace the need to learn PostgREST. Some known limitations are:
100-
101-
- Doesn't support `not`, `and`, and `or` in filtering
102-
- Many inputs are unsanitized (multi-column select, insert/update body, etc.)
103-
- Counting (with HEAD verb)
104-
- Resource embedding (embedded filters, etc.)
105-
106-
That said, if there are any features you want in, feel free to create an issue!
99+
Check out the [API docs](https://docs.rs/postgrest) for more info!
107100

108101
## Contributing
109102

110-
- Fork the repo on GitHub
111-
- Clone the project to your own machine
112-
- Commit changes to your own branch
113-
- Push your work back up to your fork
114-
- Submit a Pull request so that we can review your changes and merge
103+
Contributions are welcome! There might be some features you want in, or some
104+
unclear documentation, or a bug—either way, feel free to create an issue, and
105+
we'll work it out!
106+
107+
Boring stuff below.
115108

116109
Unless you explicitly state otherwise, any contribution intentionally submitted
117110
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
@@ -122,7 +115,7 @@ dual licensed as below, without any additional terms or conditions.
122115
Licensed under either of
123116

124117
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
125-
http://www.apache.org/licenses/LICENSE-2.0)
126-
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
118+
https://www.apache.org/licenses/LICENSE-2.0)
119+
- MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
127120

128121
at your option.

0 commit comments

Comments
 (0)