You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Installing your Wasm FDW](#installing-your-wasm-fdw)
19
+
-[Local development](#local-development)
20
+
-[Set up](#set-up)
21
+
-[Use Wasm FDW on local Supabase](#use-wasm-fdw-on-local-supabase)
22
+
-[Considerations](#considerations)
23
+
-[Version compatibility](#version-compatibility)
24
+
-[Security](#security)
25
+
-[Performance](#performance)
26
+
-[Automation](#automation)
27
+
-[Limitations](#limitations)
28
+
-[Other examples](#other-examples)
7
29
8
30
## Project Structure
9
31
@@ -94,7 +116,7 @@ This will build the Wasm file in `target/wasm32-unknown-unknown/release/wasm_fdw
94
116
95
117
### Release the Wasm FDW package
96
118
97
-
To create a release of the Wasm FDW package, create a version tag and then push it. This will trigger a workflow to build the package and create a release on GitHub.
119
+
To create a release of the Wasm FDW package, create a version tag and then push it. This will trigger a workflow to build the package and create a release on your repo.
98
120
99
121
```bash
100
122
git tag v0.1.0
@@ -133,8 +155,7 @@ Create foreign server and foreign table like below,
133
155
create server example_server
134
156
foreign data wrapper wasm_wrapper
135
157
options (
136
-
-- change below fdw_pacakge_* options accordingly
137
-
-- check available releases at https://github.com/supabase-community/wasm-fdw-example/releases
158
+
-- change below fdw_package_* options accordingly, find examples in the README.txt in your releases
:clap::clap: Congratulations! You have built your first Wasm FDW.
180
201
202
+
## Local development
203
+
204
+
### Set up
205
+
206
+
To develop Wasm FDW locally with Supabase, [Supabase CLI](https://supabase.com/docs/guides/cli/getting-started) is needed, check its docs for more installation details. After the CLI is installed, start the Supabase services:
207
+
208
+
```bash
209
+
supabase start
210
+
```
211
+
212
+
And then run the script to build the Wasm FDW package and copy it to Supabase database container:
213
+
214
+
```bash
215
+
./local-dev.sh
216
+
```
217
+
218
+
> [!TIP]
219
+
> You can also use it with [cargo watch](https://crates.io/crates/cargo-watch): `cargo watch -s ./local-dev.sh`
220
+
221
+
### Use Wasm FDW on local Supabase
222
+
223
+
Visit SQL Editor at http://127.0.0.1:54323/project/default/sql/1, create foreign server and foreign table like below,
224
+
225
+
```sql
226
+
create server example_server
227
+
foreign data wrapper wasm_wrapper
228
+
options (
229
+
-- use 'file://' schema to reference the local wasm file in container
230
+
fdw_package_url 'file:///wasm_fdw_example.wasm',
231
+
fdw_package_name 'my-company:example-fdw',
232
+
fdw_package_version '0.1.0',
233
+
api_url 'https://api.github.com'
234
+
);
235
+
236
+
createschemagithub;
237
+
238
+
create foreign table github.events (
239
+
id text,
240
+
type text,
241
+
actor jsonb,
242
+
repo jsonb,
243
+
payload jsonb,
244
+
public boolean,
245
+
created_at timestamp
246
+
)
247
+
server example_server
248
+
options (
249
+
object 'events',
250
+
rowid_column 'id'
251
+
);
252
+
```
253
+
254
+
> [!NOTE]
255
+
> The foreign server option `fdw_package_checksum` is not needed for local development.
256
+
257
+
Now you can edit and save `src/lib.rs` file, then query the foreign table like below to see result:
0 commit comments