I am working with laravel 5.1 with mongodb. For mongodb I am using jenssegers mongo configuration.
Now I have to make mongodb replica set and I want to make read operation only from slave & write operation at master.
In laravel's documentation I read that we can make separation in read & write like below:
'mysql' => [
'read' => [
'host' => '192.168.1.1',
],
'write' => [
'host' => '196.168.1.2'
],
'driver' => 'mysql',
'database' => 'database',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
],
Here is link for how to set configuration in laravel.
In jenssegers documentation here is configuration for replication:
'mongodb' => [
'driver' => 'mongodb',
'host' => ['server1', 'server2'],
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'options' => ['replicaSet' => 'replicaSetName']
],
So if I change this to:
'mongodb' => [
'driver' => 'mongodb',
'read' => ['host' => '192.168.1.1'],
'write' => ['host' => '192.168.1.2'],
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'options' => ['replicaSet' => 'replicaSetName']
],
So can I use the above configuration in jenssegers mongo db configuration?