Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var convertReadPreference = function(readPreference) {
if(readPreference && typeof readPreference == 'string') {
return new CoreReadPreference(readPreference);
} else if(readPreference instanceof ReadPreference) {
return new CoreReadPreference(readPreference.mode, readPreference.tags, {maxStalenessSeconds: readPreference.maxStalenessSeconds});
} else if(readPreference && typeof readPreference == 'object') {
var mode = readPreference.mode || readPreference.preference;
if (mode && typeof mode == 'string') {
readPreference = new CoreReadPreference(mode, readPreference.tags, {maxStalenessSeconds: readPreference.maxStalenessSeconds});
}
}
return readPreference;
}
Cursor.prototype.setReadPreference = function(r) {
if(this.s.state != Cursor.INIT) throw MongoError.create({message: 'cannot change cursor readPreference after cursor has been accessed', driver:true});
if(r instanceof ReadPreference) {
this.s.options.readPreference = new CoreReadPreference(r.mode, r.tags);
} else {
this.s.options.readPreference = new CoreReadPreference(r);
}
return this;
}
var convertReadPreference = function(readPreference) {
if(readPreference && typeof readPreference == 'string') {
return new CoreReadPreference(readPreference);
} else if(readPreference instanceof ReadPreference) {
return new CoreReadPreference(readPreference.mode, readPreference.tags);
} else if(readPreference && typeof readPreference == 'object') {
var mode = readPreference.mode || readPreference.preference;
if (mode && typeof mode == 'string') {
readPreference = new CoreReadPreference(mode, readPreference.tags);
}
}
return readPreference;
}
var getReadPreference = function(self, options, db, coll) {
var r = null
if(options.readPreference) {
r = options.readPreference
} else if(self.s.readPreference) {
r = self.s.readPreference
} else if(db.readPreference) {
r = db.readPreference;
}
if(r instanceof ReadPreference) {
options.readPreference = new CoreReadPreference(r.mode, r.tags);
} else if(typeof r == 'string') {
options.readPreference = new CoreReadPreference(r);
} else if(r && !(r instanceof ReadPreference) && typeof r == 'object') {
var mode = r.mode || r.preference;
if (mode && typeof mode == 'string') {
options.readPreference = new CoreReadPreference(mode, r.tags);
}
}
return options;
}
var convertReadPreference = function(readPreference) {
if(readPreference && typeof readPreference == 'string') {
return new CoreReadPreference(readPreference);
} else if(readPreference instanceof ReadPreference) {
return new CoreReadPreference(readPreference.mode, readPreference.tags);
} else if(readPreference && typeof readPreference == 'object') {
var mode = readPreference.mode || readPreference.preference;
if (mode && typeof mode == 'string') {
readPreference = new CoreReadPreference(mode, readPreference.tags);
}
}
return readPreference;
}
var convertReadPreference = function(readPreference) {
if(readPreference && typeof readPreference == 'string') {
return new CoreReadPreference(readPreference);
} else if(readPreference instanceof ReadPreference) {
return new CoreReadPreference(readPreference.mode, readPreference.tags);
} else if(readPreference && typeof readPreference == 'object') {
var mode = readPreference.mode || readPreference.preference;
if (mode && typeof mode == 'string') {
readPreference = new CoreReadPreference(mode, readPreference.tags);
}
}
return readPreference;
}
if(options.readPreference) {
r = options.readPreference
} else if(self.s.readPreference) {
r = self.s.readPreference
} else if(db.readPreference) {
r = db.readPreference;
}
if(r instanceof ReadPreference) {
options.readPreference = new CoreReadPreference(r.mode, r.tags);
} else if(typeof r == 'string') {
options.readPreference = new CoreReadPreference(r);
} else if(r && !(r instanceof ReadPreference) && typeof r == 'object') {
var mode = r.mode || r.preference;
if (mode && typeof mode == 'string') {
options.readPreference = new CoreReadPreference(mode, r.tags);
}
}
return options;
}
var getReadPreference = function(self, options, db, coll) {
var r = null
if(options.readPreference) {
r = options.readPreference
} else if(self.s.readPreference) {
r = self.s.readPreference
} else if(db.readPreference) {
r = db.readPreference;
}
if(r instanceof ReadPreference) {
options.readPreference = new CoreReadPreference(r.mode, r.tags);
} else if(typeof r == 'string') {
options.readPreference = new CoreReadPreference(r);
}
return options;
}
var convertReadPreference = function(readPreference) {
if(readPreference && typeof readPreference == 'string') {
return new CoreReadPreference(readPreference);
} else if(readPreference instanceof ReadPreference) {
return new CoreReadPreference(readPreference.mode, readPreference.tags, {maxStalenessSeconds: readPreference.maxStalenessSeconds});
} else if(readPreference && typeof readPreference == 'object') {
var mode = readPreference.mode || readPreference.preference;
if (mode && typeof mode == 'string') {
readPreference = new CoreReadPreference(mode, readPreference.tags, {maxStalenessSeconds: readPreference.maxStalenessSeconds});
}
}
return readPreference;
}
var convertReadPreference = function(readPreference) {
if(readPreference && typeof readPreference == 'string') {
return new CoreReadPreference(readPreference);
} else if(readPreference instanceof ReadPreference) {
return new CoreReadPreference(readPreference.mode, readPreference.tags, {maxStalenessSeconds: readPreference.maxStalenessSeconds});
} else if(readPreference && typeof readPreference == 'object') {
var mode = readPreference.mode || readPreference.preference;
if (mode && typeof mode == 'string') {
readPreference = new CoreReadPreference(mode, readPreference.tags, {maxStalenessSeconds: readPreference.maxStalenessSeconds});
}
}
return readPreference;
}