# PostgresServerResource

- Module: [Aspire.Hosting.PostgreSQL](/reference/api/go/aspire.hosting.postgresql.md)
- Version: `17.0.0`
- Kind: `handle`
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

A resource that represents a PostgreSQL container.

## Definition

```go
type PostgresServerResource interface {
    ExpressionValue
    IComputeResource
    Resource
    ResourceWithArgs
    ResourceWithConnectionString
    ResourceWithEndpoints
    ResourceWithEnvironment
    ResourceWithWaitSupport
}
```

## Embeds

- `ExpressionValue`
- `IComputeResource`
- `Resource`
- `ResourceWithArgs`
- `ResourceWithConnectionString`
- `ResourceWithEndpoints`
- `ResourceWithEnvironment`
- `ResourceWithWaitSupport`

## Properties

- `ConnectionStringExpression`: `*ReferenceExpression` `get` -- Gets the connection string expression for the PostgreSQL server.
- `Databases`: `map[string]string` `get` -- A dictionary where the key is the resource name and the value is the database name.
- `Host`: `EndpointReferenceExpression` `get` -- Gets the host endpoint reference for this service.
- `JdbcConnectionString`: `*ReferenceExpression` `get` -- Gets the JDBC connection string for the PostgreSQL server.
- `PasswordParameter`: `ParameterResource` `get/set` -- Gets or sets the parameter that contains the PostgreSQL server password.
- `Port`: `EndpointReferenceExpression` `get` -- Gets the endpoint reference expression that identifies the port for this endpoint.
- `PrimaryEndpoint`: `EndpointReference` `get` -- Gets the primary endpoint for the PostgreSQL server.
- `ResourceTypeDisplayName`: `string` `get` -- Gets the ResourceTypeDisplayName property
- `UriExpression`: `*ReferenceExpression` `get` -- Gets the connection URI expression for the PostgreSQL server.
- `UserNameParameter`: `ParameterResource` `get/set` -- Gets or sets the parameter that contains the PostgreSQL server user name.
- `UserNameReference`: `*ReferenceExpression` `get` -- Gets a reference to the user name for the PostgreSQL server.

## Methods

- [AddDatabase](/reference/api/go/aspire.hosting.postgresql/postgresserverresource/adddatabase.md) -- `method` -- Adds a PostgreSQL database to the application model.
  ```go
  AddDatabase(name string, options ...*AddDatabaseOptions) PostgresDatabaseResource
  ```
- [WithDataBindMount](/reference/api/go/aspire.hosting.postgresql/postgresserverresource/withdatabindmount.md) -- `method` -- Adds a bind mount for the data folder to a PostgreSQL container resource.
  ```go
  WithDataBindMount(source string, options ...*WithDataBindMountOptions) PostgresServerResource
  ```
- [WithDataVolume](/reference/api/go/aspire.hosting.postgresql/postgresserverresource/withdatavolume.md) -- `method` -- Adds a named volume for the data folder to a PostgreSQL container resource.
  ```go
  WithDataVolume(options ...*WithDataVolumeOptions) PostgresServerResource
  ```
- [WithHostPort](/reference/api/go/aspire.hosting.postgresql/postgresserverresource/withhostport.md) -- `method` -- Configures the host port that the PostgreSQL resource is exposed on instead of using randomly assigned port.
  ```go
  WithHostPort(port *float64) PostgresServerResource
  ```
- [WithInitFiles](/reference/api/go/aspire.hosting.postgresql/postgresserverresource/withinitfiles.md) -- `method` -- Copies init files to a PostgreSQL container resource.
  ```go
  WithInitFiles(source string) PostgresServerResource
  ```
- [WithPassword](/reference/api/go/aspire.hosting.postgresql/postgresserverresource/withpassword.md) -- `method` -- Configures the password that the PostgreSQL resource is used.
  ```go
  WithPassword(password ParameterResource) PostgresServerResource
  ```
- [WithPgAdmin](/reference/api/go/aspire.hosting.postgresql/postgresserverresource/withpgadmin.md) -- `method` -- Adds a pgAdmin 4 administration and development platform for PostgreSQL to the application model.
  ```go
  WithPgAdmin(options ...*WithPgAdminOptions) PostgresServerResource
  ```
- [WithPgWeb](/reference/api/go/aspire.hosting.postgresql/postgresserverresource/withpgweb.md) -- `method` -- Adds an administration and development platform for PostgreSQL to the application model using pgweb.
  ```go
  WithPgWeb(options ...*WithPgWebOptions) PostgresServerResource
  ```
- [WithRepl](/reference/api/go/aspire.hosting.postgresql/postgresserverresource/withrepl.md) -- `method` -- Adds a REPL command that opens an authenticated PostgreSQL shell in the dashboard terminal dock.
  ```go
  WithRepl() PostgresServerResource
  ```
- [WithUserName](/reference/api/go/aspire.hosting.postgresql/postgresserverresource/withusername.md) -- `method` -- Configures the user name that the PostgreSQL resource is used.
  ```go
  WithUserName(userName ParameterResource) PostgresServerResource
  ```
