File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ let body = resp
7474use postgrest :: Postgrest ;
7575use dotenv;
7676
77- dotenv :: dotenv (). ok ();
77+ dotenv :: dotenv (). ok ();
7878
7979let 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
95119These examples assume you've already initialized the client. The methods ` .from() ` and ` .rpc() ` initalizes the query builder inside the client.
You can’t perform that action at this time.
0 commit comments