node.js mongodb query was working fine until replica set setup and result is null -
i have followed mongo documentation @ http://docs.mongodb.org/manual/tutorial/deploy-replica-set-for-testing/ setup replica set (3 instances only) in local windows machine. tested followings , works fine:
- inserted data , connect primary using robomongo , can see data
- stop primary , 1 of secondary take on primary , data there.
- brought the 1 stopped , secondary now.
my problems:
- when use robomongo connect of secondary can't see data although there.
- my query code below return null although there data in mongodb
the connection string (no authentication needed)
mongodb://mark2:27017,mark2:27018,mark2:27019/mydb?w=0&readpreference=secondary&replset=rs0
i rs.status() , shows 3 nodes active.
{ "_id" : "rs0", "version" : 3, "members" : [ { "_id" : 0, "host" : "mark2:27017" }, { "_id" : 1, "host" : "mark2:27018" }, { "_id" : 2, "host" : "mark2:27019" } ] }
the query simple query
db.collection("user").findone({email:"yummy@gmail.com"}, function(err, result) { if(result) { // result null wasn't before setting replica set } else { } });
appreciate advice please. !
cheerio, mark thien
i sorry terrible fault. put in world database name.
Comments
Post a Comment