Skip to content

Commit 3a1d6a7

Browse files
veritemsoedirgo
authored andcommitted
feat(docs): improve documentation of pgres
1 parent a3901e8 commit 3a1d6a7

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ let body = resp
7474
use postgrest::Postgrest;
7575
use dotenv;
7676

77-
dotenv::dotenv().ok();
77+
dotenv::dotenv().ok();
7878

7979
let client = Postgrest::new("https://your.supabase.endpoint/rest/v1")
8080
.insert_header(
@@ -90,6 +90,30 @@ let body = resp
9090
.await?;
9191
```
9292

93+
if you have RLS enabled you're required to add an extra header for this libary to function correctly.
94+
95+
```rust
96+
use postgrest::Postgrest;
97+
use dotenv;
98+
99+
dotenv::dotenv().ok();
100+
101+
let client = Postgrest::new("https://your.supabase.endpoint/rest/v1/")
102+
.insert_header(
103+
"apikey",
104+
dotenv::var("SUPABASE_PUBLIC_API_KEY").unwrap())
105+
.insert_header("Authorization", format!("Bearer {}", SERVICE_KEY))
106+
107+
let resp = client
108+
.from("your_table")
109+
.select("*")
110+
.execute()
111+
.await?;
112+
let body = resp
113+
.text()
114+
.await?;
115+
```
116+
93117
### Building Queries
94118

95119
These examples assume you've already initialized the client. The methods `.from()` and `.rpc()` initalizes the query builder inside the client.

0 commit comments

Comments
 (0)