mongodb 3.2.5 → 3.3.0-beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/HISTORY.md +0 -10
  2. package/index.js +4 -4
  3. package/lib/admin.js +56 -56
  4. package/lib/aggregation_cursor.js +7 -3
  5. package/lib/bulk/common.js +18 -13
  6. package/lib/change_stream.js +196 -89
  7. package/lib/collection.js +217 -169
  8. package/lib/command_cursor.js +17 -7
  9. package/lib/core/auth/auth_provider.js +158 -0
  10. package/lib/core/auth/defaultAuthProviders.js +29 -0
  11. package/lib/core/auth/gssapi.js +241 -0
  12. package/lib/core/auth/mongo_credentials.js +81 -0
  13. package/lib/core/auth/mongocr.js +51 -0
  14. package/lib/core/auth/plain.js +35 -0
  15. package/lib/core/auth/scram.js +293 -0
  16. package/lib/core/auth/sspi.js +131 -0
  17. package/lib/core/auth/x509.js +26 -0
  18. package/lib/core/connection/apm.js +236 -0
  19. package/lib/core/connection/command_result.js +36 -0
  20. package/lib/core/connection/commands.js +507 -0
  21. package/lib/core/connection/connect.js +370 -0
  22. package/lib/core/connection/connection.js +624 -0
  23. package/lib/core/connection/logger.js +246 -0
  24. package/lib/core/connection/msg.js +219 -0
  25. package/lib/core/connection/pool.js +1285 -0
  26. package/lib/core/connection/utils.js +57 -0
  27. package/lib/core/cursor.js +752 -0
  28. package/lib/core/error.js +186 -0
  29. package/lib/core/index.js +50 -0
  30. package/lib/core/sdam/monitoring.js +228 -0
  31. package/lib/core/sdam/server.js +467 -0
  32. package/lib/core/sdam/server_description.js +163 -0
  33. package/lib/core/sdam/server_selectors.js +244 -0
  34. package/lib/core/sdam/srv_polling.js +135 -0
  35. package/lib/core/sdam/topology.js +1151 -0
  36. package/lib/core/sdam/topology_description.js +408 -0
  37. package/lib/core/sessions.js +711 -0
  38. package/lib/core/tools/smoke_plugin.js +61 -0
  39. package/lib/core/topologies/mongos.js +1337 -0
  40. package/lib/core/topologies/read_preference.js +202 -0
  41. package/lib/core/topologies/replset.js +1507 -0
  42. package/lib/core/topologies/replset_state.js +1121 -0
  43. package/lib/core/topologies/server.js +984 -0
  44. package/lib/core/topologies/shared.js +453 -0
  45. package/lib/core/transactions.js +167 -0
  46. package/lib/core/uri_parser.js +631 -0
  47. package/lib/core/utils.js +165 -0
  48. package/lib/core/wireprotocol/command.js +170 -0
  49. package/lib/core/wireprotocol/compression.js +73 -0
  50. package/lib/core/wireprotocol/constants.js +13 -0
  51. package/lib/core/wireprotocol/get_more.js +86 -0
  52. package/lib/core/wireprotocol/index.js +18 -0
  53. package/lib/core/wireprotocol/kill_cursors.js +70 -0
  54. package/lib/core/wireprotocol/query.js +224 -0
  55. package/lib/core/wireprotocol/shared.js +115 -0
  56. package/lib/core/wireprotocol/write_command.js +50 -0
  57. package/lib/cursor.js +40 -46
  58. package/lib/db.js +141 -95
  59. package/lib/dynamic_loaders.js +32 -0
  60. package/lib/error.js +12 -10
  61. package/lib/gridfs/chunk.js +2 -2
  62. package/lib/gridfs/grid_store.js +31 -25
  63. package/lib/gridfs-stream/index.js +4 -4
  64. package/lib/gridfs-stream/upload.js +1 -1
  65. package/lib/mongo_client.js +37 -15
  66. package/lib/operations/add_user.js +96 -0
  67. package/lib/operations/aggregate.js +24 -13
  68. package/lib/operations/aggregate_operation.js +127 -0
  69. package/lib/operations/bulk_write.js +104 -0
  70. package/lib/operations/close.js +47 -0
  71. package/lib/operations/collection_ops.js +28 -287
  72. package/lib/operations/collections.js +55 -0
  73. package/lib/operations/command.js +120 -0
  74. package/lib/operations/command_v2.js +43 -0
  75. package/lib/operations/common_functions.js +372 -0
  76. package/lib/operations/{mongo_client_ops.js → connect.js} +185 -157
  77. package/lib/operations/count.js +72 -0
  78. package/lib/operations/count_documents.js +46 -0
  79. package/lib/operations/create_collection.js +118 -0
  80. package/lib/operations/create_index.js +92 -0
  81. package/lib/operations/create_indexes.js +61 -0
  82. package/lib/operations/cursor_ops.js +3 -4
  83. package/lib/operations/db_ops.js +15 -12
  84. package/lib/operations/delete_many.js +25 -0
  85. package/lib/operations/delete_one.js +25 -0
  86. package/lib/operations/distinct.js +85 -0
  87. package/lib/operations/drop.js +53 -0
  88. package/lib/operations/drop_index.js +42 -0
  89. package/lib/operations/drop_indexes.js +23 -0
  90. package/lib/operations/estimated_document_count.js +33 -0
  91. package/lib/operations/execute_db_admin_command.js +34 -0
  92. package/lib/operations/execute_operation.js +165 -0
  93. package/lib/operations/explain.js +23 -0
  94. package/lib/operations/find_and_modify.js +98 -0
  95. package/lib/operations/find_one.js +33 -0
  96. package/lib/operations/find_one_and_delete.js +16 -0
  97. package/lib/operations/find_one_and_replace.js +18 -0
  98. package/lib/operations/find_one_and_update.js +19 -0
  99. package/lib/operations/geo_haystack_search.js +79 -0
  100. package/lib/operations/has_next.js +40 -0
  101. package/lib/operations/index_exists.js +39 -0
  102. package/lib/operations/index_information.js +23 -0
  103. package/lib/operations/indexes.js +22 -0
  104. package/lib/operations/insert_many.js +63 -0
  105. package/lib/operations/insert_one.js +75 -0
  106. package/lib/operations/is_capped.js +19 -0
  107. package/lib/operations/list_indexes.js +66 -0
  108. package/lib/operations/map_reduce.js +189 -0
  109. package/lib/operations/next.js +32 -0
  110. package/lib/operations/operation.js +63 -0
  111. package/lib/operations/options_operation.js +32 -0
  112. package/lib/operations/profiling_level.js +31 -0
  113. package/lib/operations/re_index.js +28 -0
  114. package/lib/operations/remove_user.js +52 -0
  115. package/lib/operations/rename.js +61 -0
  116. package/lib/operations/replace_one.js +47 -0
  117. package/lib/operations/set_profiling_level.js +48 -0
  118. package/lib/operations/stats.js +45 -0
  119. package/lib/operations/to_array.js +68 -0
  120. package/lib/operations/update_many.js +29 -0
  121. package/lib/operations/update_one.js +44 -0
  122. package/lib/operations/validate_collection.js +40 -0
  123. package/lib/read_concern.js +55 -0
  124. package/lib/topologies/mongos.js +3 -3
  125. package/lib/topologies/native_topology.js +22 -2
  126. package/lib/topologies/replset.js +3 -3
  127. package/lib/topologies/server.js +4 -4
  128. package/lib/topologies/topology_base.js +6 -6
  129. package/lib/url_parser.js +4 -3
  130. package/lib/utils.js +46 -59
  131. package/lib/write_concern.js +66 -0
  132. package/package.json +15 -6
  133. package/lib/.DS_Store +0 -0
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ const OperationBase = require('./operation').OperationBase;
4
+ const updateDocuments = require('./common_functions').updateDocuments;
5
+
6
+ class ReplaceOneOperation extends OperationBase {
7
+ constructor(collection, filter, doc, options) {
8
+ super(options);
9
+
10
+ this.collection = collection;
11
+ this.filter = filter;
12
+ this.doc = doc;
13
+ }
14
+
15
+ execute(callback) {
16
+ const coll = this.collection;
17
+ const filter = this.filter;
18
+ const doc = this.doc;
19
+ const options = this.options;
20
+
21
+ // Set single document update
22
+ options.multi = false;
23
+
24
+ // Execute update
25
+ updateDocuments(coll, filter, doc, options, (err, r) => replaceCallback(err, r, doc, callback));
26
+ }
27
+ }
28
+
29
+ function replaceCallback(err, r, doc, callback) {
30
+ if (callback == null) return;
31
+ if (err && callback) return callback(err);
32
+ if (r == null) return callback(null, { result: { ok: 1 } });
33
+
34
+ r.modifiedCount = r.result.nModified != null ? r.result.nModified : r.result.n;
35
+ r.upsertedId =
36
+ Array.isArray(r.result.upserted) && r.result.upserted.length > 0
37
+ ? r.result.upserted[0] // FIXME(major): should be `r.result.upserted[0]._id`
38
+ : null;
39
+ r.upsertedCount =
40
+ Array.isArray(r.result.upserted) && r.result.upserted.length ? r.result.upserted.length : 0;
41
+ r.matchedCount =
42
+ Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? 0 : r.result.n;
43
+ r.ops = [doc];
44
+ if (callback) callback(null, r);
45
+ }
46
+
47
+ module.exports = ReplaceOneOperation;
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ const CommandOperation = require('./command');
4
+ const levelValues = new Set(['off', 'slow_only', 'all']);
5
+
6
+ class SetProfilingLevelOperation extends CommandOperation {
7
+ constructor(db, level, options) {
8
+ let profile = 0;
9
+
10
+ if (level === 'off') {
11
+ profile = 0;
12
+ } else if (level === 'slow_only') {
13
+ profile = 1;
14
+ } else if (level === 'all') {
15
+ profile = 2;
16
+ }
17
+
18
+ super(db, options);
19
+ this.level = level;
20
+ this.profile = profile;
21
+ }
22
+
23
+ _buildCommand() {
24
+ const profile = this.profile;
25
+
26
+ // Set up the profile number
27
+ const command = { profile };
28
+
29
+ return command;
30
+ }
31
+
32
+ execute(callback) {
33
+ const level = this.level;
34
+
35
+ if (!levelValues.has(level)) {
36
+ return callback(new Error('Error: illegal profiling level value ' + level));
37
+ }
38
+
39
+ super.execute((err, doc) => {
40
+ if (err == null && doc.ok === 1) return callback(null, level);
41
+ return err != null
42
+ ? callback(err, null)
43
+ : callback(new Error('Error with profile command'), null);
44
+ });
45
+ }
46
+ }
47
+
48
+ module.exports = SetProfilingLevelOperation;
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ const Aspect = require('./operation').Aspect;
4
+ const CommandOperation = require('./command');
5
+ const defineAspects = require('./operation').defineAspects;
6
+
7
+ /**
8
+ * Get all the collection statistics.
9
+ *
10
+ * @class
11
+ * @property {Collection} a Collection instance.
12
+ * @property {object} [options] Optional settings. See Collection.prototype.stats for a list of options.
13
+ */
14
+ class StatsOperation extends CommandOperation {
15
+ /**
16
+ * Construct a Stats operation.
17
+ *
18
+ * @param {Collection} a Collection instance.
19
+ * @param {object} [options] Optional settings. See Collection.prototype.stats for a list of options.
20
+ */
21
+ constructor(collection, options) {
22
+ super(collection.s.db, options, collection);
23
+ }
24
+
25
+ _buildCommand() {
26
+ const collection = this.collection;
27
+ const options = this.options;
28
+
29
+ // Build command object
30
+ const command = {
31
+ collStats: collection.collectionName
32
+ };
33
+
34
+ // Check if we have the scale value
35
+ if (options['scale'] != null) {
36
+ command['scale'] = options['scale'];
37
+ }
38
+
39
+ return command;
40
+ }
41
+ }
42
+
43
+ defineAspects(StatsOperation, Aspect.READ_OPERATION);
44
+
45
+ module.exports = StatsOperation;
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ const Aspect = require('./operation').Aspect;
4
+ const defineAspects = require('./operation').defineAspects;
5
+ const handleCallback = require('../utils').handleCallback;
6
+ const loadCursor = require('../dynamic_loaders').loadCursor;
7
+ const OperationBase = require('./operation').OperationBase;
8
+ const push = Array.prototype.push;
9
+
10
+ class ToArrayOperation extends OperationBase {
11
+ constructor(cursor) {
12
+ super();
13
+
14
+ this.cursor = cursor;
15
+ }
16
+
17
+ execute(callback) {
18
+ const cursor = this.cursor;
19
+
20
+ let Cursor = loadCursor();
21
+
22
+ const items = [];
23
+
24
+ // Reset cursor
25
+ cursor.rewind();
26
+ cursor.s.state = Cursor.INIT;
27
+
28
+ // Fetch all the documents
29
+ const fetchDocs = () => {
30
+ cursor._next((err, doc) => {
31
+ if (err) {
32
+ return cursor._endSession
33
+ ? cursor._endSession(() => handleCallback(callback, err))
34
+ : handleCallback(callback, err);
35
+ }
36
+ if (doc == null) {
37
+ return cursor.close({ skipKillCursors: true }, () =>
38
+ handleCallback(callback, null, items)
39
+ );
40
+ }
41
+
42
+ // Add doc to items
43
+ items.push(doc);
44
+
45
+ // Get all buffered objects
46
+ if (cursor.bufferedCount() > 0) {
47
+ let docs = cursor.readBufferedDocuments(cursor.bufferedCount());
48
+
49
+ // Transform the doc if transform method added
50
+ if (cursor.s.transforms && typeof cursor.s.transforms.doc === 'function') {
51
+ docs = docs.map(cursor.s.transforms.doc);
52
+ }
53
+
54
+ push.apply(items, docs);
55
+ }
56
+
57
+ // Attempt a fetch
58
+ fetchDocs();
59
+ });
60
+ };
61
+
62
+ fetchDocs();
63
+ }
64
+ }
65
+
66
+ defineAspects(ToArrayOperation, Aspect.SKIP_SESSION);
67
+
68
+ module.exports = ToArrayOperation;
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const OperationBase = require('./operation').OperationBase;
4
+ const updateCallback = require('./common_functions').updateCallback;
5
+ const updateDocuments = require('./common_functions').updateDocuments;
6
+
7
+ class UpdateManyOperation extends OperationBase {
8
+ constructor(collection, filter, update, options) {
9
+ super(options);
10
+
11
+ this.collection = collection;
12
+ this.filter = filter;
13
+ this.update = update;
14
+ }
15
+
16
+ execute(callback) {
17
+ const coll = this.collection;
18
+ const filter = this.filter;
19
+ const update = this.update;
20
+ const options = this.options;
21
+
22
+ // Set single document update
23
+ options.multi = true;
24
+ // Execute update
25
+ updateDocuments(coll, filter, update, options, (err, r) => updateCallback(err, r, callback));
26
+ }
27
+ }
28
+
29
+ module.exports = UpdateManyOperation;
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ const OperationBase = require('./operation').OperationBase;
4
+ const updateDocuments = require('./common_functions').updateDocuments;
5
+
6
+ class UpdateOneOperation extends OperationBase {
7
+ constructor(collection, filter, update, options) {
8
+ super(options);
9
+
10
+ this.collection = collection;
11
+ this.filter = filter;
12
+ this.update = update;
13
+ }
14
+
15
+ execute(callback) {
16
+ const coll = this.collection;
17
+ const filter = this.filter;
18
+ const update = this.update;
19
+ const options = this.options;
20
+
21
+ // Set single document update
22
+ options.multi = false;
23
+ // Execute update
24
+ updateDocuments(coll, filter, update, options, (err, r) => updateCallback(err, r, callback));
25
+ }
26
+ }
27
+
28
+ function updateCallback(err, r, callback) {
29
+ if (callback == null) return;
30
+ if (err) return callback(err);
31
+ if (r == null) return callback(null, { result: { ok: 1 } });
32
+ r.modifiedCount = r.result.nModified != null ? r.result.nModified : r.result.n;
33
+ r.upsertedId =
34
+ Array.isArray(r.result.upserted) && r.result.upserted.length > 0
35
+ ? r.result.upserted[0] // FIXME(major): should be `r.result.upserted[0]._id`
36
+ : null;
37
+ r.upsertedCount =
38
+ Array.isArray(r.result.upserted) && r.result.upserted.length ? r.result.upserted.length : 0;
39
+ r.matchedCount =
40
+ Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? 0 : r.result.n;
41
+ callback(null, r);
42
+ }
43
+
44
+ module.exports = UpdateOneOperation;
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ const CommandOperation = require('./command');
4
+
5
+ class ValidateCollectionOperation extends CommandOperation {
6
+ constructor(admin, collectionName, options) {
7
+ // Decorate command with extra options
8
+ let command = { validate: collectionName };
9
+ const keys = Object.keys(options);
10
+ for (let i = 0; i < keys.length; i++) {
11
+ if (options.hasOwnProperty(keys[i]) && keys[i] !== 'session') {
12
+ command[keys[i]] = options[keys[i]];
13
+ }
14
+ }
15
+
16
+ super(admin.s.db, options, null, command);
17
+
18
+ this.collectionName;
19
+ }
20
+
21
+ execute(callback) {
22
+ const collectionName = this.collectionName;
23
+
24
+ super.execute((err, doc) => {
25
+ if (err != null) return callback(err, null);
26
+
27
+ if (doc.ok === 0) return callback(new Error('Error with validate command'), null);
28
+ if (doc.result != null && doc.result.constructor !== String)
29
+ return callback(new Error('Error with validation data'), null);
30
+ if (doc.result != null && doc.result.match(/exception|corrupt/) != null)
31
+ return callback(new Error('Error: invalid collection ' + collectionName), null);
32
+ if (doc.valid != null && !doc.valid)
33
+ return callback(new Error('Error: invalid collection ' + collectionName), null);
34
+
35
+ return callback(null, doc);
36
+ });
37
+ }
38
+ }
39
+
40
+ module.exports = ValidateCollectionOperation;
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * The **ReadConcern** class is a class that represents a MongoDB ReadConcern.
5
+ * @class
6
+ * @property {string} level The read concern level
7
+ * @see https://docs.mongodb.com/manual/reference/read-concern/index.html
8
+ */
9
+ class ReadConcern {
10
+ /**
11
+ * Constructs a ReadConcern from the read concern properties.
12
+ * @param {string} [level] The read concern level ({'local'|'available'|'majority'|'linearizable'|'snapshot'})
13
+ */
14
+ constructor(level) {
15
+ if (level != null) {
16
+ this.level = level;
17
+ }
18
+ }
19
+
20
+ /**
21
+ * Construct a ReadConcern given an options object.
22
+ *
23
+ * @param {object} options The options object from which to extract the write concern.
24
+ * @return {ReadConcern}
25
+ */
26
+ static fromOptions(options) {
27
+ if (options == null) {
28
+ return;
29
+ }
30
+
31
+ if (options.readConcern) {
32
+ return new ReadConcern(options.readConcern.level);
33
+ }
34
+
35
+ return new ReadConcern(options.level);
36
+ }
37
+
38
+ static get MAJORITY() {
39
+ return 'majority';
40
+ }
41
+
42
+ static get AVAILABLE() {
43
+ return 'available';
44
+ }
45
+
46
+ static get LINEARIZABLE() {
47
+ return 'linearizable';
48
+ }
49
+
50
+ static get SNAPSHOT() {
51
+ return 'snapshot';
52
+ }
53
+ }
54
+
55
+ module.exports = ReadConcern;
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  const TopologyBase = require('./topology_base').TopologyBase;
4
- const MongoError = require('mongodb-core').MongoError;
5
- const CMongos = require('mongodb-core').Mongos;
4
+ const MongoError = require('../core').MongoError;
5
+ const CMongos = require('../core').Mongos;
6
6
  const Cursor = require('../cursor');
7
7
  const Server = require('./server');
8
8
  const Store = require('./topology_base').Store;
@@ -165,7 +165,7 @@ class Mongos extends TopologyBase {
165
165
  ? options.socketOptions
166
166
  : options;
167
167
 
168
- // Translate all the options to the mongodb-core ones
168
+ // Translate all the options to the core types
169
169
  clonedOptions = translateOptions(clonedOptions, socketOptions);
170
170
 
171
171
  // Build default client information
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Topology = require('mongodb-core').Topology;
3
+ const Topology = require('../core').Topology;
4
4
  const ServerCapabilities = require('./topology_base').ServerCapabilities;
5
5
  const Cursor = require('../cursor');
6
6
  const translateOptions = require('../utils').translateOptions;
@@ -30,7 +30,7 @@ class NativeTopology extends Topology {
30
30
  ? options.socketOptions
31
31
  : options;
32
32
 
33
- // Translate all the options to the mongodb-core ones
33
+ // Translate all the options to the core types
34
34
  clonedOptions = translateOptions(clonedOptions, socketOptions);
35
35
 
36
36
  super(servers, clonedOptions);
@@ -47,6 +47,26 @@ class NativeTopology extends Topology {
47
47
  this.s.sCapabilities = new ServerCapabilities(this.lastIsMaster());
48
48
  return this.s.sCapabilities;
49
49
  }
50
+
51
+ // Command
52
+ command(ns, cmd, options, callback) {
53
+ super.command(ns.toString(), cmd, options, callback);
54
+ }
55
+
56
+ // Insert
57
+ insert(ns, ops, options, callback) {
58
+ super.insert(ns.toString(), ops, options, callback);
59
+ }
60
+
61
+ // Update
62
+ update(ns, ops, options, callback) {
63
+ super.update(ns.toString(), ops, options, callback);
64
+ }
65
+
66
+ // Remove
67
+ remove(ns, ops, options, callback) {
68
+ super.remove(ns.toString(), ops, options, callback);
69
+ }
50
70
  }
51
71
 
52
72
  module.exports = NativeTopology;
@@ -2,10 +2,10 @@
2
2
 
3
3
  const Server = require('./server');
4
4
  const Cursor = require('../cursor');
5
- const MongoError = require('mongodb-core').MongoError;
5
+ const MongoError = require('../core').MongoError;
6
6
  const TopologyBase = require('./topology_base').TopologyBase;
7
7
  const Store = require('./topology_base').Store;
8
- const CReplSet = require('mongodb-core').ReplSet;
8
+ const CReplSet = require('../core').ReplSet;
9
9
  const MAX_JS_INT = require('../utils').MAX_JS_INT;
10
10
  const translateOptions = require('../utils').translateOptions;
11
11
  const filterOptions = require('../utils').filterOptions;
@@ -172,7 +172,7 @@ class ReplSet extends TopologyBase {
172
172
  ? options.socketOptions
173
173
  : options;
174
174
 
175
- // Translate all the options to the mongodb-core ones
175
+ // Translate all the options to the core types
176
176
  clonedOptions = translateOptions(clonedOptions, socketOptions);
177
177
 
178
178
  // Build default client information
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const CServer = require('mongodb-core').Server;
3
+ const CServer = require('../core').Server;
4
4
  const Cursor = require('../cursor');
5
5
  const TopologyBase = require('./topology_base').TopologyBase;
6
6
  const Store = require('./topology_base').Store;
7
- const MongoError = require('mongodb-core').MongoError;
7
+ const MongoError = require('../core').MongoError;
8
8
  const MAX_JS_INT = require('../utils').MAX_JS_INT;
9
9
  const translateOptions = require('../utils').translateOptions;
10
10
  const filterOptions = require('../utils').filterOptions;
@@ -165,7 +165,7 @@ class Server extends TopologyBase {
165
165
  ? options.socketOptions
166
166
  : options;
167
167
 
168
- // Translate all the options to the mongodb-core ones
168
+ // Translate all the options to the core types
169
169
  clonedOptions = translateOptions(clonedOptions, socketOptions);
170
170
 
171
171
  // Build default client information
@@ -177,7 +177,7 @@ class Server extends TopologyBase {
177
177
 
178
178
  // Define the internal properties
179
179
  this.s = {
180
- // Create an instance of a server instance from mongodb-core
180
+ // Create an instance of a server instance from core module
181
181
  coreTopology: new CServer(clonedOptions),
182
182
  // Server capabilities
183
183
  sCapabilities: null,
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  const EventEmitter = require('events'),
4
- MongoError = require('mongodb-core').MongoError,
4
+ MongoError = require('../core').MongoError,
5
5
  f = require('util').format,
6
6
  os = require('os'),
7
7
  translateReadPreference = require('../utils').translateReadPreference,
8
- ClientSession = require('mongodb-core').Sessions.ClientSession;
8
+ ClientSession = require('../core').Sessions.ClientSession;
9
9
 
10
10
  // The store of ops
11
11
  var Store = function(topology, storeOptions) {
@@ -313,22 +313,22 @@ class TopologyBase extends EventEmitter {
313
313
 
314
314
  // Command
315
315
  command(ns, cmd, options, callback) {
316
- this.s.coreTopology.command(ns, cmd, translateReadPreference(options), callback);
316
+ this.s.coreTopology.command(ns.toString(), cmd, translateReadPreference(options), callback);
317
317
  }
318
318
 
319
319
  // Insert
320
320
  insert(ns, ops, options, callback) {
321
- this.s.coreTopology.insert(ns, ops, options, callback);
321
+ this.s.coreTopology.insert(ns.toString(), ops, options, callback);
322
322
  }
323
323
 
324
324
  // Update
325
325
  update(ns, ops, options, callback) {
326
- this.s.coreTopology.update(ns, ops, options, callback);
326
+ this.s.coreTopology.update(ns.toString(), ops, options, callback);
327
327
  }
328
328
 
329
329
  // Remove
330
330
  remove(ns, ops, options, callback) {
331
- this.s.coreTopology.remove(ns, ops, options, callback);
331
+ this.s.coreTopology.remove(ns.toString(), ops, options, callback);
332
332
  }
333
333
 
334
334
  // IsConnected
package/lib/url_parser.js CHANGED
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
- const ReadPreference = require('mongodb-core').ReadPreference,
3
+ const ReadPreference = require('./core').ReadPreference,
4
4
  parser = require('url'),
5
5
  f = require('util').format,
6
- Logger = require('mongodb-core').Logger,
6
+ Logger = require('./core').Logger,
7
7
  dns = require('dns');
8
+ const ReadConcern = require('./read_concern');
8
9
 
9
10
  module.exports = function(url, options, callback) {
10
11
  if (typeof options === 'function') (callback = options), (options = {});
@@ -441,7 +442,7 @@ function parseConnectionString(url, options) {
441
442
  dbOptions.native_parser = value === 'true';
442
443
  break;
443
444
  case 'readConcernLevel':
444
- dbOptions.readConcern = { level: value };
445
+ dbOptions.readConcern = new ReadConcern(value);
445
446
  break;
446
447
  case 'connectTimeoutMS':
447
448
  serverOptions.socketOptions.connectTimeoutMS = parseInt(value, 10);