I am making an app in nodejs and mongodb and i'm trying to connect to mongodb with the following options:
let ReadPreference = {
PRIMARY: 'PRIMARY',
PRIMARY_PREFERRED: 'PRIMARY_PREFERRED',
SECONDARY: 'secundary', // in upper or lower case gives the same error
SECONDARY_PREFERRED: 'SECONDARY_PREFERRED',
NEAREST: 'NEAREST'
};
let OPTIONS = {
poolSize: 10,
replicaSet: 'rs0', readPreference
readPreference: ReadPreference.SECONDARY
};
but I get the following error:
TypeError: Invalid read preference mode secundary.
I don't know why he throws that error at me, can you help me solve it?
code:
function connection_secondary(){
return new Promise( (resolve,reject)=>{
mongoCliR.connect('mongodb://ANY_IP:27017,ANY_IP:27017', OPTIONS,(err, db)=>{
if(err){
reject(err);
}else{
resolve(db.db('SINCO'));
}
});
})
}