Aspirerelease/17.0
Watch Aspire live streamsDocsTry Aspire

PostgresDatabaseResource

Handle
📦 Aspire.Hosting.PostgreSQL v17.0.0

A resource that represents a PostgreSQL database. This is a child resource of a PostgresServerResource.

type PostgresDatabaseResource interface {
ExpressionValue
Resource
ResourceWithConnectionString
ResourceWithParent
}

Properties

propertyConnectionStringExpression*ReferenceExpressionget
Gets the connection string expression for the Postgres database.
ConnectionStringExpression() *ReferenceExpression
propertyDatabaseNamestringget
Gets the database name.
DatabaseName() (string, error)
propertyJdbcConnectionString*ReferenceExpressionget
Gets the JDBC connection string for the PostgreSQL database.
JdbcConnectionString() *ReferenceExpression
propertyParentPostgresServerResourceget
Gets the parent PostgresSQL container resource.
Parent() PostgresServerResource
propertyResourceTypeDisplayNamestringget
Gets the ResourceTypeDisplayName property
ResourceTypeDisplayName() (string, error)
propertyUriExpression*ReferenceExpressionget
Gets the connection URI expression for the PostgreSQL database.
UriExpression() *ReferenceExpression

Methods

methodWithCreationScriptbuilder
Defines the SQL script used to create the database.
WithCreationScript(script string) PostgresDatabaseResource
scriptstringThe SQL script used to create the database.
PostgresDatabaseResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithPostgresMcpbuilder
Adds a Postgres MCP server container and configures it to connect to the database represented by builder.
WithPostgresMcp(options ...*WithPostgresMcpOptions) PostgresDatabaseResource
options...*WithPostgresMcpOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithPostgresMcpOptions argument.

ConfigureContainerfunc(obj PostgresMcpContainerResource)callbackConfiguration callback for the Postgres MCP container resource.
ContainerName*stringThe name of the container (optional).
PostgresDatabaseResource

The resource builder.

Returns a handle; failures surface later via Err().