olegp / mongo-sync

Synchronous MongoDB driver for Common Node
58 stars 13 forks source link

Replica set issues #20

Open chhib opened 10 years ago

chhib commented 10 years ago

I am trying to make the Server take arguments with replica set members by extending options such as:

this._server = new mongodb.Server(host, port, { ...
  readPreference: 'primaryPreferred'
}

I do get this error though:

MongoError: not master or secondary; cannot currently read from this replSet member

Any ideas how to make this work?

olegp commented 10 years ago

The options objects is currently ignored. I can update this to work as you described next week.

If you want to try it yourself: fork mongo-sync and update the constructor to accept a third parameter which is the options object. If that is present, then use it instead of the default arguments: https://github.com/olegp/mongo-sync/blob/master/lib/mongo-sync.js