1
- # postgrest-rs 🦀
1
+ # postgrest-rs
2
2
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 )
4
6
[ ![ License: Apache-2.0 OR MIT] ( https://img.shields.io/crates/l/postgrest.svg )] ( #license )
5
7
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 .
7
9
8
10
## Usage
9
11
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
+ ```
13
18
14
19
Simple example:
15
20
16
21
``` rust
17
22
use postgrest :: Postgrest ;
18
23
19
- let client = Postgrest :: new (" https://your- postgrest- endpoint" );
24
+ let client = Postgrest :: new (" https://your. postgrest. endpoint" );
20
25
let resp = client
21
26
. from (" your_table" )
22
27
. select (" *" )
@@ -64,54 +69,42 @@ _Not enough filters_:
64
69
``` rust
65
70
let resp = client
66
71
. from (" countries" )
67
- . eq (" name" , " New Zealand" )
72
+ . eq (" name" , " New Zealand" ) // You can filter for equality...
68
73
. gt (" id" , " 20" )
69
74
. lt (" id" , " 20" )
70
75
. gte (" id" , " 20" )
71
76
. lte (" id" , " 20" )
72
- . like (" name" , " %United%" )
77
+ . like (" name" , " %United%" ) // ...do pattern matching...
73
78
. ilike (" name" , " %United%" )
74
79
. is (" name" , " null" )
75
80
. in_ (" name" , vec! [" China" , " France" ])
76
81
. neq (" name" , " China" )
77
- . fts (" phrase" , " The Fat Cats" , Some (" english" ))
82
+ . fts (" phrase" , " The Fat Cats" , Some (" english" )) // ...do full text search...
78
83
. plfts (" phrase" , " The Fat Cats" , None )
79
84
. phfts (" phrase" , " The Fat Cats" , Some (" english" ))
80
85
. wfts (" phrase" , " The Fat Cats" , None )
81
86
. cs (" countries" , " (10,20)" )
82
87
. cd (" countries" , " (10,20)" )
83
88
. 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
87
92
. nxr (" population_range" , (100 , 500 ))
88
93
. adj (" population_range" , (100 , 500 ))
89
94
. select (" *" )
90
95
. execute ()
91
96
. await ? ;
92
97
```
93
98
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!
107
100
108
101
## Contributing
109
102
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.
115
108
116
109
Unless you explicitly state otherwise, any contribution intentionally submitted
117
110
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.
122
115
Licensed under either of
123
116
124
117
- 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 )
127
120
128
121
at your option.
0 commit comments