https://github.com/solid-software/deno_postgres_interop
🦖 Deno Postgres driver interop
https://github.com/solid-software/deno_postgres_interop
dart deno-deploy postgres supabase
Last synced: 9 months ago
JSON representation
🦖 Deno Postgres driver interop
- Host: GitHub
- URL: https://github.com/solid-software/deno_postgres_interop
- Owner: solid-software
- License: bsd-3-clause
- Created: 2023-09-06T18:58:59.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-02T18:14:26.000Z (over 2 years ago)
- Last Synced: 2024-11-14T13:20:26.685Z (over 1 year ago)
- Topics: dart, deno-deploy, postgres, supabase
- Language: Dart
- Homepage:
- Size: 171 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# deno_postgres_interop
[](https://pub.dev/packages/solid_lints)
[](https://nokycucwgzweensacwfy.supabase.co/functions/v1/get_project_url?projectId=241)
The package allows the use
of [Deno Postgres](https://deno.land/x/postgres)
in [Deno Deploy](https://deno.com/deploy)
on [dart_edge](https://docs.dartedge.dev/)
by creating interop bindings for the js library
since other drivers rely on dart:io and don't work there.
The main scenario is Supabase Edge Functions, but it should also work for other cases with dart2js.
## Usage with Supabase edge functions
1. Add dependency in your pubspec.yaml:
```yaml
dependencies:
deno_postgres_interop:
```
or run
```bash
dart pub add deno_postgres_interop
```
2. Add the config file (default name is `add_imports.yaml`).
This file is used to lookup files where the classes are defined.
```yaml
file_url_prefix: 'https://deno.land/x/postgres@v0.17.0/'
classes_map:
'query/query.ts':
- QueryObjectResult
'mod.ts':
- QueryClient
- Client
- Transaction
```
3. Import the package:
```dart
import 'package:deno_postgres_interop/deno_postgres_interop.dart';
```
4. Compile the code that uses this package with:
```bash
dart run edge build supabase_functions
```
5. Add imports to generated file by calling the script:
```bash
dart run deno_postgres_interop:add_imports \
--filename=example/functions/dart_edge/main.dart.js [\
--configpath=add_imports.yaml] #this is the default value
```
Note: your filename may differ from the example
6. You can use the function now.
Note that because of the [bug in dart_edge](https://github.com/invertase/dart_edge/issues/50), SDK versions >= 3.1.0 are not actually supported.