# MongoDBReplicaSetResource

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

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 resourceTypeDisplayName: string;
  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.
- `resourceTypeDisplayName`: `string` `get` -- Gets the ResourceTypeDisplayName property
- `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
  ```
