Skip to content

solid-software/deno_postgres_interop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deno_postgres_interop

style: solid deno_postgres_interop

The package allows the use of Deno Postgres in Deno Deploy on dart_edge 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:

    dependencies:
      deno_postgres_interop: <INSERT LATEST VERSION>

    or run

    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.

    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:

    import 'package:deno_postgres_interop/deno_postgres_interop.dart';
  4. Compile the code that uses this package with:

    dart run edge build supabase_functions
  5. Add imports to generated file by calling the script:

    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, SDK versions >= 3.1.0 are not actually supported.