christkv/node-mongodb-native — Issue #490: TypeError: Cannot read property 'arbiterOnly' of undefined
Author: Ralle
Created: 2012-01-29 12:03:38+00:00
State: open

I am getting this error
```/Users/ralle/Dropbox/Projects/tipe/xmpp/node_modules/mongodb/lib/mongodb/connection/server.js:549
if(self.isMasterDoc['arbiterOnly'] == true) {
^
TypeError: Cannot read property 'arbiterOnly' of undefined
at /Users/ralle/Dropbox/Projects/tipe/xmpp/node_modules/mongodb/lib/mongodb/connection/server.js:549:22
at [object Object].checkoutReader (/Users/ralle/Dropbox/Projects/tipe/xmpp/node_modules/mongodb/lib/mongodb/connection/server.js:566:16)
at /Users/ralle/Dropbox/Projects/tipe/xmpp/node_modules/mongodb/lib/mongodb/db.js:835:79
at [object Object]._executeQueryCommand (/Users/ralle/Dropbox/Projects/tipe/xmpp/node_modules/mongodb/lib/mongodb/db.js:1028:5)
at Collection.count (/Users/ralle/Dropbox/Projects/tipe/xmpp/node_modules/mongodb/lib/mongodb/collection.js:514:11)
at [object Object].count (/Users/ralle/Dropbox/Projects/tipe/xmpp/node_modules/mongodb/lib/mongodb/cursor.js:211:19)
at /Users/ralle/Dropbox/Projects/tipe/xmpp/tipe_datamanager.js:22:16
at Collection.find (/Users/ralle/Dropbox/Projects/tipe/xmpp/node_modules/mongodb/lib/mongodb/collection.js:834:5)
at /Users/ralle/Dropbox/Projects/tipe/xmpp/tipe_datamanager.js:20:18
at [object Object].collection (/Users/ralle/Dropbox/Projects/tipe/xmpp/node_modules/mongodb/lib/mongodb/db.js:320:44)```

with this code:

``` self.db = new Db('tipe', new Server(host, port, {}), {});

self.userCreate = function(username, password, callback) {
self.db.collection('users', function(err, collection) {
console.log('Collection',err);
collection.find({username: username}, function(err, cursor) {
console.log('Find', err);
cursor.count(function(err, count) {
console.log('Count', err);
if (count == 0) {
// create user
collection.insert({username: username, password: password});
callback(0);
} else {
// user already exists
callback(1);
}
});
});
});
};
```