Quantcast
Channel: StackExchange Replication Questions
Viewing all articles
Browse latest Browse all 17268

MongoDB replica set - copyDatabase with readPreference?

$
0
0

From the docs on Connection String URI Syntax with respect to replica sets we have:

The following connects to a replica set with three members and distributes reads to the secondaries:

mongodb://example1.com,example2.com/?replicaSet=test&readPreference=secondary

This is exactly what I need to do, however I'm trying to determine the correct syntax to use (and if readPreference is even supported) for the copyDatabase command. Its host URI syntax looks like this:

test/example1.com,example2.com

...for example...

db.copyDatabase('myDb', 'myDb', 'test/example1.com,example2.com')

Can I tack ?readPreference=secondary on the end of that and have it work as expected? I don't have a convenient way to test this myself in my environment or I would. Hoping someone here may know off the top of their head.


Viewing all articles
Browse latest Browse all 17268

Trending Articles