# MongoDBReplicaSetResource

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

Represents a MongoDB replica set resource in the application model. A replica set is a group of MongoDB servers that maintain the same data set, providing redundancy and high availability.

## Definition

```typescript
interface MongoDBReplicaSetResource
  extends IExpressionValue,
    IManifestExpressionProvider,
    IResource,
    IResourceWithConnectionString,
    IResourceWithWaitSupport,
    IValueProvider,
    IValueWithReferences {
  readonly connectionStringExpression: ReferenceExpression;
  readonly members: MongoDBServerResource[];
  readonly sharedKeyFileParameter: ParameterResource;
  readonly sharedPasswordParameter: ParameterResource;
  readonly sharedUserNameParameter: ParameterResource;
  readonly sharedUserNameReference: ReferenceExpression;
  withMember(member: MongoDBServerResource): MongoDBReplicaSetResource;
}
```

## Properties

- `connectionStringExpression`: `ReferenceExpression` `get` -- Gets the combined connection string for the MongoDB replica set, which includes the endpoints of all members, interpretable by the MongoDB driver.
- `members`: `MongoDBServerResource[]` `get` -- Gets the MongoDB server resources that are members of this replica set, in the order they were added.
- `sharedKeyFileParameter`: `ParameterResource` `get` -- Gets the parameter that contains the content of the key file used for internal authentication between members of the MongoDB replica set.
- `sharedPasswordParameter`: `ParameterResource` `get` -- Gets the parameter that contains the password for authenticating to the MongoDB replica set.
- `sharedUserNameParameter`: `ParameterResource` `get` -- Gets the parameter that contains the username for authenticating to the MongoDB replica set.
- `sharedUserNameReference`: `ReferenceExpression` `get` -- Gets a reference to the username for the MongoDB replica set.

## Methods

- [withMember](/reference/api/typescript/aspire.hosting.mongodb/mongodbreplicasetresource/withmember.md) -- `method` -- Adds a MongoDB server resource as a member of the replica set.
    ```typescript
  withMember(member: MongoDBServerResource): MongoDBReplicaSetResource
  ```
