Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Commit

Permalink
PERL-568 Document replica set connection in MongoDB.pm and MongoClient
Browse files Browse the repository at this point in the history
  • Loading branch information
xdg committed Sep 22, 2015
1 parent 0e7430d commit 360eead
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/MongoDB.pm
Expand Up @@ -65,6 +65,11 @@ for L<MongoDB::MongoClient::new|MongoDB::MongoClient/ATTRIBUTES>.
If an error occurs, a L<MongoDB::Error> object will be thrown.
B<NOTE>: To connect to a replica set, a replica set name must be provided.
For example, if the set name is "setA":
$client = MongoDB->connect("mongodb://example.com/?replicaSet=setA");
=cut

sub connect {
Expand Down
5 changes: 5 additions & 0 deletions lib/MongoDB/MongoClient.pm
Expand Up @@ -1526,6 +1526,11 @@ send_write_op
replica_set_name => 'myset',
);
# connect to a replica set with URI (set name *required*)
my $client = MongoDB::MongoClient->new(
host => "mongodb://mongo1.example.com,mongo2.example.com/?replicaSet=myset",
);
my $db = $client->get_database("test");
my $coll = $db->get_collection("people");
Expand Down

0 comments on commit 360eead

Please sign in to comment.