# MongoDBServerResource

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

A resource that represents a MongoDB container.

## Definition

```typescript
interface MongoDBServerResource
  extends IComputeResource,
    IExpressionValue,
    IManifestExpressionProvider,
    IResource,
    IResourceWithArgs,
    IResourceWithConnectionString,
    IResourceWithEndpoints,
    IResourceWithEnvironment,
    IResourceWithProbes,
    IResourceWithWaitSupport,
    IValueProvider,
    IValueWithReferences {
  readonly connectionStringExpression: ReferenceExpression;
  readonly databases: Dict<string,string>;
  readonly host: EndpointReferenceExpression;
  readonly passwordParameter: ParameterResource;
  readonly port: EndpointReferenceExpression;
  readonly primaryEndpoint: EndpointReference;
  readonly uriExpression: ReferenceExpression;
  readonly userNameParameter: ParameterResource;
  readonly userNameReference: ReferenceExpression;
  addDatabase(
      name: string,
      databaseName?: string): MongoDBDatabaseResource;
  withDataBindMount(
      source: string,
      isReadOnly?: boolean): MongoDBServerResource;
  withDataVolume(
      name?: string,
      isReadOnly?: boolean): MongoDBServerResource;
  withInitFiles(source: string): MongoDBServerResource;
  withMongoExpress(configureContainer?: (obj: MongoExpressContainerResource) => Promise<void>, containerName?: string): MongoDBServerResource;
}
```

## Properties

- `connectionStringExpression`: `ReferenceExpression` `get` -- Gets the connection string for the MongoDB server.
- `databases`: `Dict<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` -- 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.
- `uriExpression`: `ReferenceExpression` `get` -- Gets the connection URI expression for the MongoDB server.
- `userNameParameter`: `ParameterResource` `get` -- 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/typescript/aspire.hosting.mongodb/mongodbserverresource/adddatabase.md) -- `method` -- Adds a MongoDB database to the application model.
    ```typescript
  addDatabase(name: string, databaseName?: string): MongoDBDatabaseResource
  ```
- [withDataBindMount](/reference/api/typescript/aspire.hosting.mongodb/mongodbserverresource/withdatabindmount.md) -- `method` -- Adds a bind mount for the data folder to a MongoDB container resource.
    ```typescript
  withDataBindMount(source: string, isReadOnly?: boolean): MongoDBServerResource
  ```
- [withDataVolume](/reference/api/typescript/aspire.hosting.mongodb/mongodbserverresource/withdatavolume.md) -- `method` -- Adds a named volume for the data folder to a MongoDB container resource.
    ```typescript
  withDataVolume(name?: string, isReadOnly?: boolean): MongoDBServerResource
  ```
- [withInitFiles](/reference/api/typescript/aspire.hosting.mongodb/mongodbserverresource/withinitfiles.md) -- `method` -- Copies init files into a MongoDB container resource.
    ```typescript
  withInitFiles(source: string): MongoDBServerResource
  ```
- [withMongoExpress](/reference/api/typescript/aspire.hosting.mongodb/mongodbserverresource/withmongoexpress.md) -- `method` -- Adds a MongoExpress administration and development platform for MongoDB to the application model.
    ```typescript
  withMongoExpress(configureContainer?: (obj: MongoExpressContainerResource) => Promise<void>, containerName?: string): MongoDBServerResource
  ```
