How to use the Server function from mongodb
Find comprehensive JavaScript mongodb.Server code examples handpicked from public code repositorys.
155 156 157 158 159 160 161 162 163 164
This is one of the ways to establish a connection to the MongoDB server in which the `db` variable will hold a reference to the database at a specified host and port: ```js const Db = mongodb.Db const Connection = mongodb.Connection const Server = mongodb.Server const host = '127.0.0.1' const port = 27017 const db = new Db ('test', new Server(host,port, {}))
220
505
53
+ 14 other calls in file
33 34 35 36 37 38 39 40 41 42
Use ReplSet ```js var mongo = require('mongoskin'); var Server = mongo.Server; var Db = mongo.Db; var replSet = new ReplSetServers([ new Server('localhost', 30000),
174
0
67
+ 11 other calls in file
GitHub: Mist-apps/mist-api
183 184 185 186 187 188 189 190 191 192
logger.warn('[DB] Unable to open "' + dbName + '" database connection: database already opened'); if (callback) callback(null); return; } // Create the database connection var server = new mongo.Server(database.host, database.port, {auto_reconnect: true}); connections[dbName] = new mongo.Db(dbName, server, {safe: true}); // Connect to the DB connections[dbName].open(function (err, newDb) { if (err) {
0
1
2
+ 10 other calls in file
mongodb.ObjectId is the most popular function in mongodb (5685 examples)