showing results for - "mongoerror 3a mongoclient must be connected before calling mongoclient prototype db"
Greta
11 Apr 2020
1var MongoClient = require('mongodb').MongoClient;
2
3MongoClient.connect("mongodb://localhost:30000,localhost:30001/integration_test_?w=0&readPreference=secondary", function(err, db) {
4  test.equal(null, err);
5  test.ok(db != null);
6
7  db.collection("replicaset_mongo_client_collection").update({a:1}, {b:1}, {upsert:true}, function(err, result) {
8    test.equal(null, err);
9    test.equal(1, result);
10
11    db.close();
12    test.done();
13  });
14});
15
Anaïs
27 Apr 2016
1var MongoClient = require('mongodb').MongoClient;
2
3MongoClient.connect("mongodb://localhost:50000,localhost:50001/integration_test_?w=0&readPreference=secondary", function(err, db) {
4  test.equal(null, err);
5  test.ok(db != null);
6
7  db.collection("replicaset_mongo_client_collection").update({a:1}, {b:1}, {upsert:true}, function(err, result) {
8    test.equal(null, err);
9    test.equal(1, result);
10
11    db.close();
12    test.done();
13  });
14});
15