db-migrate / db-migrate/mongodb

Add support for ReplSet and associated options

Open
#25 9 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
25
Forks
57
PR merge metrics
No merged PRs in 30d

Description

Hey again @wzrdtales !

Sorry if the title is unclear. Right now in the mongo driver we have the following:
```
db = config.db || new MongoClient(new Server(host, port));
```

And I'm hoping to change it to something which has support for ReplSet and associated options:
```
db = config.db || new MongoClient(new ReplSet(servers, options));
```

---

I think my general approach would be to try to avoid changing the API and add additional optional options to the `config`. Perhaps something like:

```
var mongoClient;
if (config.replSet) {
var hosts = config.replSet.split(',');
var servers = hosts.map(function(host) {
return new Server(host, port, config.replSetOptions);
});
db = config.db || new MongoClient(new ReplSet(servers, config.replSetOptions));
} else {
db = config.db || new MongoClient(new Server(host, port));
}
```

Before I went ahead and figured the rest out I figured I'd double check with you that this seems reasonable and you'd be amenable to a PR for this. Also please let me know if you have any implementation requests. And, as always, thanks for the work you do :)

---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/57175517-add-support-for-replset-and-associated-options?utm_campaign=plugin&utm_content=tracker%2F12293389&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F12293389&utm_medium=issues&utm_source=github).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.