# MongoDBServerResource

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

A resource that represents a MongoDB container.

## Definition

```go
type MongoDBServerResource 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 for the MongoDB 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 resource.
- `PasswordParameter`: `ParameterResource` `get/set` -- Gets the parameter that contains the MongoDb server password.
- `Port`: `EndpointReferenceExpression` `get` -- Gets the port endpoint reference for this resource.
- `PrimaryEndpoint`: `EndpointReference` `get` -- Gets the primary endpoint for the MongoDB server.
- `ReplicaSetName`: `*string` `get/set` -- Gets the name of the replica set this MongoDB server belongs to, or `null` if it is not part of a replica set.
- `ResourceTypeDisplayName`: `string` `get` -- Gets the ResourceTypeDisplayName property
- `TlsEnabled`: `bool` `get` -- Gets a value indicating whether TLS is enabled for the MongoDB server.
- `UriExpression`: `*ReferenceExpression` `get` -- Gets the connection URI expression for the MongoDB server.
- `UserNameParameter`: `ParameterResource` `get/set` -- Gets the parameter that contains the MongoDb server username.
- `UserNameReference`: `*ReferenceExpression` `get` -- Gets a reference to the user name for the MongoDB server.

## Methods

- [AddDatabase](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource/adddatabase.md) -- `method` -- Adds a MongoDB database to the application model.
  ```go
  AddDatabase(name string, options ...*AddDatabaseOptions) MongoDBDatabaseResource
  ```
- [WithBindIpAll](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource/withbindipall.md) -- `method` -- Configures the MongoDB server to bind to and listen on all network interfaces.
  ```go
  WithBindIpAll() MongoDBServerResource
  ```
- [WithDataBindMount](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource/withdatabindmount.md) -- `method` -- Adds a bind mount for the data folder to a MongoDB container resource.
  ```go
  WithDataBindMount(source string, options ...*WithDataBindMountOptions) MongoDBServerResource
  ```
- [WithDataVolume](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource/withdatavolume.md) -- `method` -- Adds a named volume for the data folder to a MongoDB container resource.
  ```go
  WithDataVolume(options ...*WithDataVolumeOptions) MongoDBServerResource
  ```
- [WithInitFiles](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource/withinitfiles.md) -- `method` -- Copies init files into a MongoDB container resource.
  ```go
  WithInitFiles(source string) MongoDBServerResource
  ```
- [WithKeyFile](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource/withkeyfile.md) -- `method` -- Sets up a keyfile for internal authentication between members of a MongoDB replica set, with the specified `keyValue` as the content of the file.
  ```go
  WithKeyFile(keyValue ExpressionValue, options ...*WithKeyFileOptions) MongoDBServerResource
  ```
- [WithMongoExpress](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource/withmongoexpress.md) -- `method` -- Adds a MongoExpress administration and development platform for MongoDB to the application model.
  ```go
  WithMongoExpress(options ...*WithMongoExpressOptions) MongoDBServerResource
  ```
- [WithRepl](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource/withrepl.md) -- `method` -- Adds a REPL command that opens an authenticated MongoDB shell in the dashboard terminal dock.
  ```go
  WithRepl() MongoDBServerResource
  ```
- [WithReplicaSet](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource/withreplicaset.md) -- `method` -- Configures and initializes the MongoDB server as a single-member replica set for local development.
  ```go
  WithReplicaSet(options ...*WithReplicaSetOptions) MongoDBServerResource
  ```
- [WithTlsAllowInvalidCertificates](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource/withtlsallowinvalidcertificates.md) -- `method` -- Configures the MongoDB server to accept TLS connections whose peer certificate cannot be validated, by passing `--tlsAllowInvalidCertificates` to `mongod`.
  ```go
  WithTlsAllowInvalidCertificates() MongoDBServerResource
  ```
- [WithTlsMode](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource/withtlsmode.md) -- `method` -- Configures the `--tlsMode` the MongoDB server is started with when TLS is active.
  ```go
  WithTlsMode(options ...*WithTlsModeOptions) MongoDBServerResource
  ```
