-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
you can declare a DB by defining a type that implements `PostgresDatabaseConfig` (the only supported interface implementing `DatabaseConfig`, at present): ``` type MyConfig struct {} // name provides the DB name func (MyConfig) Name() string { return "testdb" } // tags the type as a DB decl func (MyConfig) db() // tags the DB type as `postgres` func (MyConfig pg() ``` to avoid the verbosity of implementing `db()` and `pg()`, you can instead embed `ftl.DefaultPostgresDatabaseConfig`. this will implement these "tag" methods but not any required methods, e.g. `Name()` which must be explicitly provided in the user code. ``` type MyConfig struct { ftl.DefaultPostgresDatabaseConfig } // name provides the DB name func (MyConfig) Name() string { return "testdb" } ``` you can then use the DB you've configured by injecting a handle around its config into a verb signature: ``` //ftl:verb func Query(ctx context.Context, in Request, db ftl.DatabaseHandle[MyConfig]) (Response, error) { db.Get(ctx).Exec(...) // ... } ``` eventually we will extend `DatabaseConfig` with additional methods, e.g. RAM, disk, max connections, etc. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.