Reputation: 2854
I'm developing an app, which has mongodb as database. I'm using multiple URLs to connect mongodb. I have used following to connect DB.
var mongoClient = require('mongodb').MongoClient;
var Db = require('mongodb').Db;
var Server = require('mongodb').Server;
var ReplSetServers = require('mongodb').ReplSetServers;
var replSet = new ReplSetServers([
new Server('localhost', 30000),
new Server('localhost', 30001),
new Server('localhost', 30002)
]);
var db = new Db('machaao', replSet, {w:0});
After importing package by using require
I didn't get any error. But after using new ReplSetServers
I got the following error. TypeError: ReplSetServers is not a function
.
Are there any dependency packages that I have to import? or should I make changes in code? I have no idea why that error comes. And I haven't found any related answer on Google.
Any help would be appreciated.
Upvotes: 1
Views: 290
Reputation: 12627
The ReplSetServers
referred to in the error TypeError: ReplSetServers is not a function
refers to the last line.
var db = new Db('machaao', ReplSetServers, {w:0});
should be
var db = new Db('machaao', replSet, {w:0});`
Upvotes: 1