Skip to content

Instantly share code, notes, and snippets.

@lukewagner
Created April 16, 2024 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukewagner/e4bab34bbe73d4ce9cb6d8959bc69243 to your computer and use it in GitHub Desktop.
Save lukewagner/e4bab34bbe73d4ce9cb6d8959bc69243 to your computer and use it in GitHub Desktop.
multi-db support
package postgres:api {
interface connection {
query: func(...) -> ...;
execute: func(...) -> ...;
}
interface connections {
*: connection;
}
interface runtime-connections {
resource connection = resourceify(connection);
open: func(name: string) -> connection;
}
}
world my-single-db-world {
import postgres:api/connection;
}
world my-declarative-multi-db-world {
import postgres:api/connections;
}
world my-dynamic-db-world {
import postgres:api/runtime-connections;
}
world or-heck-maybe-i-do-both {
import postgres:api/connections;
import postgres:api/runtime-connections;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment