mongodb 4.0.0 → 4.1.2
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.
- package/README.md +62 -30
- package/lib/bson.js +1 -0
- package/lib/bson.js.map +1 -1
- package/lib/bulk/common.js +53 -30
- package/lib/bulk/common.js.map +1 -1
- package/lib/bulk/ordered.js +3 -2
- package/lib/bulk/ordered.js.map +1 -1
- package/lib/bulk/unordered.js +3 -2
- package/lib/bulk/unordered.js.map +1 -1
- package/lib/change_stream.js +23 -13
- package/lib/change_stream.js.map +1 -1
- package/lib/cmap/auth/auth_provider.js +2 -1
- package/lib/cmap/auth/auth_provider.js.map +1 -1
- package/lib/cmap/auth/gssapi.js +5 -4
- package/lib/cmap/auth/gssapi.js.map +1 -1
- package/lib/cmap/auth/mongo_credentials.js +9 -5
- package/lib/cmap/auth/mongo_credentials.js.map +1 -1
- package/lib/cmap/auth/mongocr.js +2 -2
- package/lib/cmap/auth/mongocr.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js +32 -32
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/auth/plain.js +1 -1
- package/lib/cmap/auth/plain.js.map +1 -1
- package/lib/cmap/auth/scram.js +15 -12
- package/lib/cmap/auth/scram.js.map +1 -1
- package/lib/cmap/auth/x509.js +2 -2
- package/lib/cmap/auth/x509.js.map +1 -1
- package/lib/cmap/command_monitoring_events.js +26 -10
- package/lib/cmap/command_monitoring_events.js.map +1 -1
- package/lib/cmap/commands.js +9 -5
- package/lib/cmap/commands.js.map +1 -1
- package/lib/cmap/connect.js +23 -9
- package/lib/cmap/connect.js.map +1 -1
- package/lib/cmap/connection.js +43 -46
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +113 -15
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/connection_pool_events.js +3 -1
- package/lib/cmap/connection_pool_events.js.map +1 -1
- package/lib/cmap/errors.js +3 -3
- package/lib/cmap/errors.js.map +1 -1
- package/lib/cmap/message_stream.js +1 -1
- package/lib/cmap/message_stream.js.map +1 -1
- package/lib/cmap/metrics.js +62 -0
- package/lib/cmap/metrics.js.map +1 -0
- package/lib/cmap/stream_description.js +3 -1
- package/lib/cmap/stream_description.js.map +1 -1
- package/lib/cmap/wire_protocol/compression.js +22 -9
- package/lib/cmap/wire_protocol/compression.js.map +1 -1
- package/lib/cmap/wire_protocol/shared.js +1 -1
- package/lib/cmap/wire_protocol/shared.js.map +1 -1
- package/lib/collection.js +23 -18
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +76 -30
- package/lib/connection_string.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +75 -68
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/aggregation_cursor.js +47 -9
- package/lib/cursor/aggregation_cursor.js.map +1 -1
- package/lib/cursor/find_cursor.js +53 -13
- package/lib/cursor/find_cursor.js.map +1 -1
- package/lib/db.js +21 -14
- package/lib/db.js.map +1 -1
- package/lib/deps.js +16 -5
- package/lib/deps.js.map +1 -1
- package/lib/encrypter.js +5 -8
- package/lib/encrypter.js.map +1 -1
- package/lib/error.js +230 -34
- package/lib/error.js.map +1 -1
- package/lib/explain.js +2 -2
- package/lib/explain.js.map +1 -1
- package/lib/gridfs/download.js +22 -47
- package/lib/gridfs/download.js.map +1 -1
- package/lib/gridfs/index.js +4 -3
- package/lib/gridfs/index.js.map +1 -1
- package/lib/gridfs/upload.js +13 -21
- package/lib/gridfs/upload.js.map +1 -1
- package/lib/index.js +27 -2
- package/lib/index.js.map +1 -1
- package/lib/logger.js +3 -2
- package/lib/logger.js.map +1 -1
- package/lib/mongo_client.js +5 -8
- package/lib/mongo_client.js.map +1 -1
- package/lib/mongo_types.js.map +1 -1
- package/lib/operations/add_user.js +2 -3
- package/lib/operations/add_user.js.map +1 -1
- package/lib/operations/aggregate.js +12 -9
- package/lib/operations/aggregate.js.map +1 -1
- package/lib/operations/command.js +5 -7
- package/lib/operations/command.js.map +1 -1
- package/lib/operations/common_functions.js +1 -1
- package/lib/operations/common_functions.js.map +1 -1
- package/lib/operations/connect.js +3 -2
- package/lib/operations/connect.js.map +1 -1
- package/lib/operations/count.js +1 -1
- package/lib/operations/count.js.map +1 -1
- package/lib/operations/count_documents.js +1 -1
- package/lib/operations/count_documents.js.map +1 -1
- package/lib/operations/delete.js +5 -5
- package/lib/operations/delete.js.map +1 -1
- package/lib/operations/distinct.js +2 -2
- package/lib/operations/distinct.js.map +1 -1
- package/lib/operations/estimated_document_count.js +5 -1
- package/lib/operations/estimated_document_count.js.map +1 -1
- package/lib/operations/eval.js.map +1 -1
- package/lib/operations/execute_operation.js +31 -17
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find.js +13 -9
- package/lib/operations/find.js.map +1 -1
- package/lib/operations/find_and_modify.js +9 -9
- package/lib/operations/find_and_modify.js.map +1 -1
- package/lib/operations/indexes.js +8 -3
- package/lib/operations/indexes.js.map +1 -1
- package/lib/operations/insert.js +5 -3
- package/lib/operations/insert.js.map +1 -1
- package/lib/operations/is_capped.js +2 -1
- package/lib/operations/is_capped.js.map +1 -1
- package/lib/operations/list_collections.js +6 -3
- package/lib/operations/list_collections.js.map +1 -1
- package/lib/operations/map_reduce.js +1 -1
- package/lib/operations/map_reduce.js.map +1 -1
- package/lib/operations/operation.js +3 -1
- package/lib/operations/operation.js.map +1 -1
- package/lib/operations/options_operation.js +2 -1
- package/lib/operations/options_operation.js.map +1 -1
- package/lib/operations/profiling_level.js +4 -2
- package/lib/operations/profiling_level.js.map +1 -1
- package/lib/operations/set_profiling_level.js +4 -2
- package/lib/operations/set_profiling_level.js.map +1 -1
- package/lib/operations/update.js +12 -12
- package/lib/operations/update.js.map +1 -1
- package/lib/operations/validate_collection.js +6 -5
- package/lib/operations/validate_collection.js.map +1 -1
- package/lib/promise_provider.js +1 -1
- package/lib/promise_provider.js.map +1 -1
- package/lib/read_preference.js +8 -8
- package/lib/read_preference.js.map +1 -1
- package/lib/sdam/common.js +12 -10
- package/lib/sdam/common.js.map +1 -1
- package/lib/sdam/server.js +90 -25
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/server_description.js +9 -4
- package/lib/sdam/server_description.js.map +1 -1
- package/lib/sdam/server_selection.js +10 -4
- package/lib/sdam/server_selection.js.map +1 -1
- package/lib/sdam/srv_polling.js +1 -1
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sdam/topology.js +42 -21
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sdam/topology_description.js +7 -3
- package/lib/sdam/topology_description.js.map +1 -1
- package/lib/sessions.js +132 -31
- package/lib/sessions.js.map +1 -1
- package/lib/sort.js +3 -3
- package/lib/sort.js.map +1 -1
- package/lib/transactions.js +15 -7
- package/lib/transactions.js.map +1 -1
- package/lib/utils.js +60 -20
- package/lib/utils.js.map +1 -1
- package/mongodb.d.ts +523 -138
- package/mongodb.ts34.d.ts +480 -141
- package/package.json +44 -48
- package/src/bson.ts +1 -0
- package/src/bulk/common.ts +83 -43
- package/src/bulk/ordered.ts +4 -3
- package/src/bulk/unordered.ts +4 -3
- package/src/change_stream.ts +46 -29
- package/src/cmap/auth/auth_provider.ts +3 -2
- package/src/cmap/auth/gssapi.ts +15 -5
- package/src/cmap/auth/mongo_credentials.ts +22 -8
- package/src/cmap/auth/mongocr.ts +3 -3
- package/src/cmap/auth/mongodb_aws.ts +52 -39
- package/src/cmap/auth/plain.ts +2 -2
- package/src/cmap/auth/scram.ts +23 -13
- package/src/cmap/auth/x509.ts +3 -3
- package/src/cmap/command_monitoring_events.ts +36 -14
- package/src/cmap/commands.ts +12 -6
- package/src/cmap/connect.ts +42 -12
- package/src/cmap/connection.ts +54 -62
- package/src/cmap/connection_pool.ts +141 -20
- package/src/cmap/connection_pool_events.ts +8 -1
- package/src/cmap/errors.ts +3 -4
- package/src/cmap/message_stream.ts +2 -4
- package/src/cmap/metrics.ts +58 -0
- package/src/cmap/stream_description.ts +6 -1
- package/src/cmap/wire_protocol/compression.ts +26 -13
- package/src/cmap/wire_protocol/shared.ts +4 -2
- package/src/collection.ts +75 -70
- package/src/connection_string.ts +97 -34
- package/src/cursor/abstract_cursor.ts +141 -104
- package/src/cursor/aggregation_cursor.ts +34 -20
- package/src/cursor/find_cursor.ts +41 -21
- package/src/db.ts +19 -18
- package/src/deps.ts +110 -22
- package/src/encrypter.ts +6 -12
- package/src/error.ts +264 -48
- package/src/explain.ts +3 -3
- package/src/gridfs/download.ts +48 -53
- package/src/gridfs/index.ts +5 -4
- package/src/gridfs/upload.ts +32 -33
- package/src/index.ts +42 -4
- package/src/logger.ts +6 -3
- package/src/mongo_client.ts +20 -23
- package/src/mongo_types.ts +19 -20
- package/src/operations/add_user.ts +4 -5
- package/src/operations/aggregate.ts +18 -17
- package/src/operations/command.ts +7 -10
- package/src/operations/common_functions.ts +2 -3
- package/src/operations/connect.ts +4 -3
- package/src/operations/count.ts +2 -2
- package/src/operations/count_documents.ts +2 -2
- package/src/operations/delete.ts +8 -6
- package/src/operations/distinct.ts +5 -3
- package/src/operations/estimated_document_count.ts +5 -1
- package/src/operations/eval.ts +1 -1
- package/src/operations/execute_operation.ts +41 -20
- package/src/operations/find.ts +25 -16
- package/src/operations/find_and_modify.ts +12 -10
- package/src/operations/indexes.ts +39 -8
- package/src/operations/insert.ts +7 -4
- package/src/operations/is_capped.ts +3 -2
- package/src/operations/list_collections.ts +9 -6
- package/src/operations/map_reduce.ts +4 -2
- package/src/operations/operation.ts +7 -2
- package/src/operations/options_operation.ts +3 -2
- package/src/operations/profiling_level.ts +5 -3
- package/src/operations/set_profiling_level.ts +9 -3
- package/src/operations/update.ts +17 -13
- package/src/operations/validate_collection.ts +7 -6
- package/src/promise_provider.ts +2 -2
- package/src/read_preference.ts +11 -9
- package/src/sdam/common.ts +11 -9
- package/src/sdam/server.ts +168 -69
- package/src/sdam/server_description.ts +16 -4
- package/src/sdam/server_selection.ts +15 -7
- package/src/sdam/srv_polling.ts +2 -2
- package/src/sdam/topology.ts +67 -36
- package/src/sdam/topology_description.ts +11 -4
- package/src/sessions.ts +194 -37
- package/src/sort.ts +6 -4
- package/src/transactions.ts +18 -9
- package/src/utils.ts +73 -20
- package/HISTORY.md +0 -2993
- package/lib/operations/find_one.js +0 -34
- package/lib/operations/find_one.js.map +0 -1
- package/src/operations/find_one.ts +0 -43
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReadPreference } from '../read_preference';
|
|
2
2
|
import { maxWireVersion, decorateWithCollation, hasAtomicOperators, Callback } from '../utils';
|
|
3
|
-
import {
|
|
3
|
+
import { MongoInvalidArgumentError, MongoCompatibilityError } from '../error';
|
|
4
4
|
import { CommandOperation, CommandOperationOptions } from './command';
|
|
5
5
|
import { defineAspects, Aspect } from './operation';
|
|
6
6
|
import type { Document } from '../bson';
|
|
@@ -172,7 +172,7 @@ class FindAndModifyOperation extends CommandOperation<Document> {
|
|
|
172
172
|
const unacknowledgedWrite = this.writeConcern?.w === 0;
|
|
173
173
|
if (unacknowledgedWrite || maxWireVersion(server) < 8) {
|
|
174
174
|
callback(
|
|
175
|
-
new
|
|
175
|
+
new MongoCompatibilityError(
|
|
176
176
|
'The current topology does not support a hint on findAndModify commands'
|
|
177
177
|
)
|
|
178
178
|
);
|
|
@@ -185,7 +185,9 @@ class FindAndModifyOperation extends CommandOperation<Document> {
|
|
|
185
185
|
|
|
186
186
|
if (this.explain && maxWireVersion(server) < 4) {
|
|
187
187
|
callback(
|
|
188
|
-
new
|
|
188
|
+
new MongoCompatibilityError(
|
|
189
|
+
`Server ${server.name} does not support explain on findAndModify`
|
|
190
|
+
)
|
|
189
191
|
);
|
|
190
192
|
return;
|
|
191
193
|
}
|
|
@@ -203,7 +205,7 @@ export class FindOneAndDeleteOperation extends FindAndModifyOperation {
|
|
|
203
205
|
constructor(collection: Collection, filter: Document, options: FindOneAndDeleteOptions) {
|
|
204
206
|
// Basic validation
|
|
205
207
|
if (filter == null || typeof filter !== 'object') {
|
|
206
|
-
throw new
|
|
208
|
+
throw new MongoInvalidArgumentError('Argument "filter" must be an object');
|
|
207
209
|
}
|
|
208
210
|
|
|
209
211
|
super(collection, filter, options);
|
|
@@ -220,15 +222,15 @@ export class FindOneAndReplaceOperation extends FindAndModifyOperation {
|
|
|
220
222
|
options: FindOneAndReplaceOptions
|
|
221
223
|
) {
|
|
222
224
|
if (filter == null || typeof filter !== 'object') {
|
|
223
|
-
throw new
|
|
225
|
+
throw new MongoInvalidArgumentError('Argument "filter" must be an object');
|
|
224
226
|
}
|
|
225
227
|
|
|
226
228
|
if (replacement == null || typeof replacement !== 'object') {
|
|
227
|
-
throw new
|
|
229
|
+
throw new MongoInvalidArgumentError('Argument "replacement" must be an object');
|
|
228
230
|
}
|
|
229
231
|
|
|
230
232
|
if (hasAtomicOperators(replacement)) {
|
|
231
|
-
throw new
|
|
233
|
+
throw new MongoInvalidArgumentError('Replacement document must not contain atomic operators');
|
|
232
234
|
}
|
|
233
235
|
|
|
234
236
|
super(collection, filter, options);
|
|
@@ -246,15 +248,15 @@ export class FindOneAndUpdateOperation extends FindAndModifyOperation {
|
|
|
246
248
|
options: FindOneAndUpdateOptions
|
|
247
249
|
) {
|
|
248
250
|
if (filter == null || typeof filter !== 'object') {
|
|
249
|
-
throw new
|
|
251
|
+
throw new MongoInvalidArgumentError('Argument "filter" must be an object');
|
|
250
252
|
}
|
|
251
253
|
|
|
252
254
|
if (update == null || typeof update !== 'object') {
|
|
253
|
-
throw new
|
|
255
|
+
throw new MongoInvalidArgumentError('Argument "update" must be an object');
|
|
254
256
|
}
|
|
255
257
|
|
|
256
258
|
if (!hasAtomicOperators(update)) {
|
|
257
|
-
throw new
|
|
259
|
+
throw new MongoInvalidArgumentError('Update document requires atomic operators');
|
|
258
260
|
}
|
|
259
261
|
|
|
260
262
|
super(collection, filter, options);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { indexInformation, IndexInformationOptions } from './common_functions';
|
|
2
2
|
import { AbstractOperation, Aspect, defineAspects } from './operation';
|
|
3
|
-
import { MONGODB_ERROR_CODES,
|
|
3
|
+
import { MONGODB_ERROR_CODES, MongoServerError, MongoCompatibilityError } from '../error';
|
|
4
4
|
import {
|
|
5
5
|
maxWireVersion,
|
|
6
6
|
parseIndexOptions,
|
|
@@ -35,6 +35,7 @@ const VALID_INDEX_OPTIONS = new Set([
|
|
|
35
35
|
'expireAfterSeconds',
|
|
36
36
|
'storageEngine',
|
|
37
37
|
'collation',
|
|
38
|
+
'version',
|
|
38
39
|
|
|
39
40
|
// text indexes
|
|
40
41
|
'weights',
|
|
@@ -70,7 +71,28 @@ export type IndexSpecification = OneOrMore<
|
|
|
70
71
|
>;
|
|
71
72
|
|
|
72
73
|
/** @public */
|
|
73
|
-
export interface IndexDescription
|
|
74
|
+
export interface IndexDescription
|
|
75
|
+
extends Pick<
|
|
76
|
+
CreateIndexesOptions,
|
|
77
|
+
| 'background'
|
|
78
|
+
| 'unique'
|
|
79
|
+
| 'partialFilterExpression'
|
|
80
|
+
| 'sparse'
|
|
81
|
+
| 'hidden'
|
|
82
|
+
| 'expireAfterSeconds'
|
|
83
|
+
| 'storageEngine'
|
|
84
|
+
| 'version'
|
|
85
|
+
| 'weights'
|
|
86
|
+
| 'default_language'
|
|
87
|
+
| 'language_override'
|
|
88
|
+
| 'textIndexVersion'
|
|
89
|
+
| '2dsphereIndexVersion'
|
|
90
|
+
| 'bits'
|
|
91
|
+
| 'min'
|
|
92
|
+
| 'max'
|
|
93
|
+
| 'bucketSize'
|
|
94
|
+
| 'wildcardProjection'
|
|
95
|
+
> {
|
|
74
96
|
collation?: CollationOptions;
|
|
75
97
|
name?: string;
|
|
76
98
|
key: Document;
|
|
@@ -90,9 +112,12 @@ export interface CreateIndexesOptions extends CommandOperationOptions {
|
|
|
90
112
|
sparse?: boolean;
|
|
91
113
|
/** Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) */
|
|
92
114
|
expireAfterSeconds?: number;
|
|
115
|
+
/** Allows users to configure the storage engine on a per-index basis when creating an index. (MongoDB 3.0 or higher) */
|
|
93
116
|
storageEngine?: Document;
|
|
94
117
|
/** (MongoDB 4.4. or higher) Specifies how many data-bearing members of a replica set, including the primary, must complete the index builds successfully before the primary marks the indexes as ready. This option accepts the same values for the "w" field in a write concern plus "votingMembers", which indicates all voting data-bearing nodes. */
|
|
95
118
|
commitQuorum?: number | string;
|
|
119
|
+
/** Specifies the index version number, either 0 or 1. */
|
|
120
|
+
version?: number;
|
|
96
121
|
// text indexes
|
|
97
122
|
weights?: Document;
|
|
98
123
|
default_language?: string;
|
|
@@ -110,6 +135,8 @@ export interface CreateIndexesOptions extends CommandOperationOptions {
|
|
|
110
135
|
bucketSize?: number;
|
|
111
136
|
// wildcard indexes
|
|
112
137
|
wildcardProjection?: Document;
|
|
138
|
+
/** Specifies that the index should exist on the target collection but should not be used by the query planner when executing operations. (MongoDB 4.4 or higher) */
|
|
139
|
+
hidden?: boolean;
|
|
113
140
|
}
|
|
114
141
|
|
|
115
142
|
function makeIndexSpec(indexSpec: IndexSpecification, options: any): IndexDescription {
|
|
@@ -132,7 +159,7 @@ function makeIndexSpec(indexSpec: IndexSpecification, options: any): IndexDescri
|
|
|
132
159
|
}
|
|
133
160
|
|
|
134
161
|
/** @internal */
|
|
135
|
-
export class IndexesOperation extends AbstractOperation<Document> {
|
|
162
|
+
export class IndexesOperation extends AbstractOperation<Document[]> {
|
|
136
163
|
options: IndexInformationOptions;
|
|
137
164
|
collection: Collection;
|
|
138
165
|
|
|
@@ -142,7 +169,7 @@ export class IndexesOperation extends AbstractOperation<Document> {
|
|
|
142
169
|
this.collection = collection;
|
|
143
170
|
}
|
|
144
171
|
|
|
145
|
-
execute(server: Server, session: ClientSession, callback: Callback<Document>): void {
|
|
172
|
+
execute(server: Server, session: ClientSession, callback: Callback<Document[]>): void {
|
|
146
173
|
const coll = this.collection;
|
|
147
174
|
const options = this.options;
|
|
148
175
|
|
|
@@ -188,7 +215,7 @@ export class CreateIndexesOperation<
|
|
|
188
215
|
// Did the user pass in a collation, check if our write server supports it
|
|
189
216
|
if (indexes[i].collation && serverWireVersion < 5) {
|
|
190
217
|
callback(
|
|
191
|
-
new
|
|
218
|
+
new MongoCompatibilityError(
|
|
192
219
|
`Server ${server.name}, which reports wire version ${serverWireVersion}, ` +
|
|
193
220
|
'does not support collation'
|
|
194
221
|
)
|
|
@@ -213,8 +240,8 @@ export class CreateIndexesOperation<
|
|
|
213
240
|
if (options.commitQuorum != null) {
|
|
214
241
|
if (serverWireVersion < 9) {
|
|
215
242
|
callback(
|
|
216
|
-
new
|
|
217
|
-
'`commitQuorum`
|
|
243
|
+
new MongoCompatibilityError(
|
|
244
|
+
'Option `commitQuorum` for `createIndexes` not supported on servers < 4.4'
|
|
218
245
|
)
|
|
219
246
|
);
|
|
220
247
|
return;
|
|
@@ -486,7 +513,11 @@ export class IndexInformationOperation extends AbstractOperation<Document> {
|
|
|
486
513
|
}
|
|
487
514
|
}
|
|
488
515
|
|
|
489
|
-
defineAspects(ListIndexesOperation, [
|
|
516
|
+
defineAspects(ListIndexesOperation, [
|
|
517
|
+
Aspect.READ_OPERATION,
|
|
518
|
+
Aspect.RETRYABLE,
|
|
519
|
+
Aspect.CURSOR_CREATING
|
|
520
|
+
]);
|
|
490
521
|
defineAspects(CreateIndexesOperation, [Aspect.WRITE_OPERATION]);
|
|
491
522
|
defineAspects(CreateIndexOperation, [Aspect.WRITE_OPERATION]);
|
|
492
523
|
defineAspects(EnsureIndexOperation, [Aspect.WRITE_OPERATION]);
|
package/src/operations/insert.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MongoServerError, MongoInvalidArgumentError } from '../error';
|
|
2
2
|
import { defineAspects, Aspect, AbstractOperation } from './operation';
|
|
3
3
|
import { CommandOperation, CommandOperationOptions } from './command';
|
|
4
4
|
import { prepareDocs } from './common_functions';
|
|
@@ -37,7 +37,7 @@ export class InsertOperation extends CommandOperation<Document> {
|
|
|
37
37
|
command.bypassDocumentValidation = options.bypassDocumentValidation;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
if (
|
|
40
|
+
if (options.comment != null) {
|
|
41
41
|
command.comment = options.comment;
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -70,7 +70,10 @@ export class InsertOneOperation extends InsertOperation {
|
|
|
70
70
|
super.execute(server, session, (err, res) => {
|
|
71
71
|
if (err || res == null) return callback(err);
|
|
72
72
|
if (res.code) return callback(new MongoServerError(res));
|
|
73
|
-
if (res.writeErrors)
|
|
73
|
+
if (res.writeErrors) {
|
|
74
|
+
// This should be a WriteError but we can't change it now because of error hierarchy
|
|
75
|
+
return callback(new MongoServerError(res.writeErrors[0]));
|
|
76
|
+
}
|
|
74
77
|
|
|
75
78
|
callback(undefined, {
|
|
76
79
|
acknowledged: this.writeConcern?.w !== 0 ?? true,
|
|
@@ -100,7 +103,7 @@ export class InsertManyOperation extends AbstractOperation<InsertManyResult> {
|
|
|
100
103
|
super(options);
|
|
101
104
|
|
|
102
105
|
if (!Array.isArray(docs)) {
|
|
103
|
-
throw new
|
|
106
|
+
throw new MongoInvalidArgumentError('Argument "docs" must be an array of documents');
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
this.options = options;
|
|
@@ -3,7 +3,7 @@ import type { Collection } from '../collection';
|
|
|
3
3
|
import { OperationOptions, AbstractOperation } from './operation';
|
|
4
4
|
import type { Server } from '../sdam/server';
|
|
5
5
|
import type { ClientSession } from '../sessions';
|
|
6
|
-
import {
|
|
6
|
+
import { MongoAPIError } from '../error';
|
|
7
7
|
|
|
8
8
|
/** @internal */
|
|
9
9
|
export class IsCappedOperation extends AbstractOperation<boolean> {
|
|
@@ -27,7 +27,8 @@ export class IsCappedOperation extends AbstractOperation<boolean> {
|
|
|
27
27
|
.toArray((err, collections) => {
|
|
28
28
|
if (err || !collections) return callback(err);
|
|
29
29
|
if (collections.length === 0) {
|
|
30
|
-
|
|
30
|
+
// TODO(NODE-3485)
|
|
31
|
+
return callback(new MongoAPIError(`collection ${coll.namespace} not found`));
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
const collOptions = collections[0].options;
|
|
@@ -46,10 +46,7 @@ export class ListCollectionsOperation extends CommandOperation<string[]> {
|
|
|
46
46
|
const databaseName = this.db.s.namespace.db;
|
|
47
47
|
|
|
48
48
|
// If we have legacy mode and have not provided a full db name filter it
|
|
49
|
-
if (
|
|
50
|
-
typeof filter.name === 'string' &&
|
|
51
|
-
!new RegExp('^' + databaseName + '\\.').test(filter.name)
|
|
52
|
-
) {
|
|
49
|
+
if (typeof filter.name === 'string' && !new RegExp(`^${databaseName}\\.`).test(filter.name)) {
|
|
53
50
|
filter = Object.assign({}, filter);
|
|
54
51
|
filter.name = this.db.s.namespace.withCollection(filter.name).toString();
|
|
55
52
|
}
|
|
@@ -118,7 +115,9 @@ export interface CollectionInfo extends Document {
|
|
|
118
115
|
|
|
119
116
|
/** @public */
|
|
120
117
|
export class ListCollectionsCursor<
|
|
121
|
-
T extends Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo =
|
|
118
|
+
T extends Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo =
|
|
119
|
+
| Pick<CollectionInfo, 'name' | 'type'>
|
|
120
|
+
| CollectionInfo
|
|
122
121
|
> extends AbstractCursor<T> {
|
|
123
122
|
parent: Db;
|
|
124
123
|
filter: Document;
|
|
@@ -155,4 +154,8 @@ export class ListCollectionsCursor<
|
|
|
155
154
|
}
|
|
156
155
|
}
|
|
157
156
|
|
|
158
|
-
defineAspects(ListCollectionsOperation, [
|
|
157
|
+
defineAspects(ListCollectionsOperation, [
|
|
158
|
+
Aspect.READ_OPERATION,
|
|
159
|
+
Aspect.RETRYABLE,
|
|
160
|
+
Aspect.CURSOR_CREATING
|
|
161
|
+
]);
|
|
@@ -12,7 +12,7 @@ import { CommandOperation, CommandOperationOptions } from './command';
|
|
|
12
12
|
import type { Server } from '../sdam/server';
|
|
13
13
|
import type { Collection } from '../collection';
|
|
14
14
|
import type { Sort } from '../sort';
|
|
15
|
-
import {
|
|
15
|
+
import { MongoServerError, MongoCompatibilityError } from '../error';
|
|
16
16
|
import type { ObjectId } from '../bson';
|
|
17
17
|
import { Aspect, defineAspects } from './operation';
|
|
18
18
|
import type { ClientSession } from '../sessions';
|
|
@@ -165,7 +165,9 @@ export class MapReduceOperation extends CommandOperation<Document | Document[]>
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
if (this.explain && maxWireVersion(server) < 9) {
|
|
168
|
-
callback(
|
|
168
|
+
callback(
|
|
169
|
+
new MongoCompatibilityError(`Server ${server.name} does not support explain on mapReduce`)
|
|
170
|
+
);
|
|
169
171
|
return;
|
|
170
172
|
}
|
|
171
173
|
|
|
@@ -9,7 +9,8 @@ export const Aspect = {
|
|
|
9
9
|
WRITE_OPERATION: Symbol('WRITE_OPERATION'),
|
|
10
10
|
RETRYABLE: Symbol('RETRYABLE'),
|
|
11
11
|
EXPLAINABLE: Symbol('EXPLAINABLE'),
|
|
12
|
-
SKIP_COLLATION: Symbol('SKIP_COLLATION')
|
|
12
|
+
SKIP_COLLATION: Symbol('SKIP_COLLATION'),
|
|
13
|
+
CURSOR_CREATING: Symbol('CURSOR_CREATING')
|
|
13
14
|
} as const;
|
|
14
15
|
|
|
15
16
|
/** @public */
|
|
@@ -27,6 +28,9 @@ export interface OperationOptions extends BSONSerializeOptions {
|
|
|
27
28
|
|
|
28
29
|
/** The preferred read preference (ReadPreference.primary, ReadPreference.primary_preferred, ReadPreference.secondary, ReadPreference.secondary_preferred, ReadPreference.nearest). */
|
|
29
30
|
readPreference?: ReadPreferenceLike;
|
|
31
|
+
|
|
32
|
+
/** @internal Hints to `executeOperation` that this operation should not unpin on an ended transaction */
|
|
33
|
+
bypassPinningCheck?: boolean;
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
/** @internal */
|
|
@@ -44,7 +48,7 @@ export abstract class AbstractOperation<TResult = any> {
|
|
|
44
48
|
cmd!: Document;
|
|
45
49
|
readPreference: ReadPreference;
|
|
46
50
|
server!: Server;
|
|
47
|
-
|
|
51
|
+
bypassPinningCheck: boolean;
|
|
48
52
|
|
|
49
53
|
// BSON serialization options
|
|
50
54
|
bsonOptions?: BSONSerializeOptions;
|
|
@@ -67,6 +71,7 @@ export abstract class AbstractOperation<TResult = any> {
|
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
this.options = options;
|
|
74
|
+
this.bypassPinningCheck = !!options.bypassPinningCheck;
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
abstract execute(server: Server, session: ClientSession, callback: Callback<TResult>): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractOperation, OperationOptions } from './operation';
|
|
2
|
-
import {
|
|
2
|
+
import { MongoAPIError } from '../error';
|
|
3
3
|
import type { Callback } from '../utils';
|
|
4
4
|
import type { Document } from '../bson';
|
|
5
5
|
import type { Collection } from '../collection';
|
|
@@ -28,7 +28,8 @@ export class OptionsOperation extends AbstractOperation<Document> {
|
|
|
28
28
|
.toArray((err, collections) => {
|
|
29
29
|
if (err || !collections) return callback(err);
|
|
30
30
|
if (collections.length === 0) {
|
|
31
|
-
|
|
31
|
+
// TODO(NODE-3485)
|
|
32
|
+
return callback(new MongoAPIError(`collection ${coll.namespace} not found`));
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
callback(err, collections[0].options);
|
|
@@ -3,7 +3,7 @@ import type { Callback } from '../utils';
|
|
|
3
3
|
import type { Server } from '../sdam/server';
|
|
4
4
|
import type { Db } from '../db';
|
|
5
5
|
import type { ClientSession } from '../sessions';
|
|
6
|
-
import {
|
|
6
|
+
import { MongoRuntimeError } from '../error';
|
|
7
7
|
|
|
8
8
|
/** @public */
|
|
9
9
|
export type ProfilingLevelOptions = CommandOperationOptions;
|
|
@@ -24,9 +24,11 @@ export class ProfilingLevelOperation extends CommandOperation<string> {
|
|
|
24
24
|
if (was === 0) return callback(undefined, 'off');
|
|
25
25
|
if (was === 1) return callback(undefined, 'slow_only');
|
|
26
26
|
if (was === 2) return callback(undefined, 'all');
|
|
27
|
-
|
|
27
|
+
// TODO(NODE-3483)
|
|
28
|
+
return callback(new MongoRuntimeError(`Illegal profiling level value ${was}`));
|
|
28
29
|
} else {
|
|
29
|
-
|
|
30
|
+
// TODO(NODE-3483): Consider MongoUnexpectedServerResponseError
|
|
31
|
+
err != null ? callback(err) : callback(new MongoRuntimeError('Error with profile command'));
|
|
30
32
|
}
|
|
31
33
|
});
|
|
32
34
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { CommandOperation, CommandOperationOptions } from './command';
|
|
2
2
|
import type { Callback } from '../utils';
|
|
3
|
+
import { enumToString } from '../utils';
|
|
3
4
|
import type { Server } from '../sdam/server';
|
|
4
5
|
import type { Db } from '../db';
|
|
5
6
|
import type { ClientSession } from '../sessions';
|
|
6
|
-
import {
|
|
7
|
+
import { MongoRuntimeError, MongoInvalidArgumentError } from '../error';
|
|
7
8
|
const levelValues = new Set(['off', 'slow_only', 'all']);
|
|
8
9
|
|
|
9
10
|
/** @public */
|
|
@@ -50,14 +51,19 @@ export class SetProfilingLevelOperation extends CommandOperation<ProfilingLevel>
|
|
|
50
51
|
const level = this.level;
|
|
51
52
|
|
|
52
53
|
if (!levelValues.has(level)) {
|
|
53
|
-
return callback(
|
|
54
|
+
return callback(
|
|
55
|
+
new MongoInvalidArgumentError(
|
|
56
|
+
`Profiling level must be one of "${enumToString(ProfilingLevel)}"`
|
|
57
|
+
)
|
|
58
|
+
);
|
|
54
59
|
}
|
|
55
60
|
|
|
61
|
+
// TODO(NODE-3483): Determine error to put here
|
|
56
62
|
super.executeCommand(server, session, { profile: this.profile }, (err, doc) => {
|
|
57
63
|
if (err == null && doc.ok === 1) return callback(undefined, level);
|
|
58
64
|
return err != null
|
|
59
65
|
? callback(err)
|
|
60
|
-
: callback(new
|
|
66
|
+
: callback(new MongoRuntimeError('Error with profile command'));
|
|
61
67
|
});
|
|
62
68
|
}
|
|
63
69
|
}
|
package/src/operations/update.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { Server } from '../sdam/server';
|
|
|
11
11
|
import type { Collection } from '../collection';
|
|
12
12
|
import type { ObjectId, Document } from '../bson';
|
|
13
13
|
import type { ClientSession } from '../sessions';
|
|
14
|
-
import {
|
|
14
|
+
import { MongoServerError, MongoInvalidArgumentError, MongoCompatibilityError } from '../error';
|
|
15
15
|
|
|
16
16
|
/** @public */
|
|
17
17
|
export interface UpdateOptions extends CommandOperationOptions {
|
|
@@ -108,25 +108,29 @@ export class UpdateOperation extends CommandOperation<Document> {
|
|
|
108
108
|
collationNotSupported(server, options) ||
|
|
109
109
|
(statementWithCollation && collationNotSupported(server, statementWithCollation))
|
|
110
110
|
) {
|
|
111
|
-
callback(new
|
|
111
|
+
callback(new MongoCompatibilityError(`Server ${server.name} does not support collation`));
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0;
|
|
116
116
|
if (unacknowledgedWrite || maxWireVersion(server) < 5) {
|
|
117
117
|
if (this.statements.find((o: Document) => o.hint)) {
|
|
118
|
-
callback(new
|
|
118
|
+
callback(new MongoCompatibilityError(`Servers < 3.4 do not support hint on update`));
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
if (this.explain && maxWireVersion(server) < 3) {
|
|
124
|
-
callback(
|
|
124
|
+
callback(
|
|
125
|
+
new MongoCompatibilityError(`Server ${server.name} does not support explain on update`)
|
|
126
|
+
);
|
|
125
127
|
return;
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
if (this.statements.some(statement => !!statement.arrayFilters) && maxWireVersion(server) < 6) {
|
|
129
|
-
callback(
|
|
131
|
+
callback(
|
|
132
|
+
new MongoCompatibilityError('Option "arrayFilters" is only supported on MongoDB 3.6+')
|
|
133
|
+
);
|
|
130
134
|
return;
|
|
131
135
|
}
|
|
132
136
|
|
|
@@ -144,7 +148,7 @@ export class UpdateOneOperation extends UpdateOperation {
|
|
|
144
148
|
);
|
|
145
149
|
|
|
146
150
|
if (!hasAtomicOperators(update)) {
|
|
147
|
-
throw new
|
|
151
|
+
throw new MongoInvalidArgumentError('Update document requires atomic operators');
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
154
|
|
|
@@ -155,7 +159,7 @@ export class UpdateOneOperation extends UpdateOperation {
|
|
|
155
159
|
): void {
|
|
156
160
|
super.execute(server, session, (err, res) => {
|
|
157
161
|
if (err || !res) return callback(err);
|
|
158
|
-
if (
|
|
162
|
+
if (this.explain != null) return callback(undefined, res);
|
|
159
163
|
if (res.code) return callback(new MongoServerError(res));
|
|
160
164
|
if (res.writeErrors) return callback(new MongoServerError(res.writeErrors[0]));
|
|
161
165
|
|
|
@@ -181,7 +185,7 @@ export class UpdateManyOperation extends UpdateOperation {
|
|
|
181
185
|
);
|
|
182
186
|
|
|
183
187
|
if (!hasAtomicOperators(update)) {
|
|
184
|
-
throw new
|
|
188
|
+
throw new MongoInvalidArgumentError('Update document requires atomic operators');
|
|
185
189
|
}
|
|
186
190
|
}
|
|
187
191
|
|
|
@@ -192,7 +196,7 @@ export class UpdateManyOperation extends UpdateOperation {
|
|
|
192
196
|
): void {
|
|
193
197
|
super.execute(server, session, (err, res) => {
|
|
194
198
|
if (err || !res) return callback(err);
|
|
195
|
-
if (
|
|
199
|
+
if (this.explain != null) return callback(undefined, res);
|
|
196
200
|
if (res.code) return callback(new MongoServerError(res));
|
|
197
201
|
if (res.writeErrors) return callback(new MongoServerError(res.writeErrors[0]));
|
|
198
202
|
|
|
@@ -235,7 +239,7 @@ export class ReplaceOneOperation extends UpdateOperation {
|
|
|
235
239
|
);
|
|
236
240
|
|
|
237
241
|
if (hasAtomicOperators(replacement)) {
|
|
238
|
-
throw new
|
|
242
|
+
throw new MongoInvalidArgumentError('Replacement document must not contain atomic operators');
|
|
239
243
|
}
|
|
240
244
|
}
|
|
241
245
|
|
|
@@ -246,7 +250,7 @@ export class ReplaceOneOperation extends UpdateOperation {
|
|
|
246
250
|
): void {
|
|
247
251
|
super.execute(server, session, (err, res) => {
|
|
248
252
|
if (err || !res) return callback(err);
|
|
249
|
-
if (
|
|
253
|
+
if (this.explain != null) return callback(undefined, res);
|
|
250
254
|
if (res.code) return callback(new MongoServerError(res));
|
|
251
255
|
if (res.writeErrors) return callback(new MongoServerError(res.writeErrors[0]));
|
|
252
256
|
|
|
@@ -268,11 +272,11 @@ export function makeUpdateStatement(
|
|
|
268
272
|
options: UpdateOptions & { multi?: boolean }
|
|
269
273
|
): UpdateStatement {
|
|
270
274
|
if (filter == null || typeof filter !== 'object') {
|
|
271
|
-
throw new
|
|
275
|
+
throw new MongoInvalidArgumentError('Selector must be a valid JavaScript object');
|
|
272
276
|
}
|
|
273
277
|
|
|
274
278
|
if (update == null || typeof update !== 'object') {
|
|
275
|
-
throw new
|
|
279
|
+
throw new MongoInvalidArgumentError('Document must be a valid JavaScript object');
|
|
276
280
|
}
|
|
277
281
|
|
|
278
282
|
const op: UpdateStatement = { q: filter, u: update };
|
|
@@ -4,7 +4,7 @@ import type { Document } from '../bson';
|
|
|
4
4
|
import type { Server } from '../sdam/server';
|
|
5
5
|
import type { Admin } from '../admin';
|
|
6
6
|
import type { ClientSession } from '../sessions';
|
|
7
|
-
import {
|
|
7
|
+
import { MongoRuntimeError } from '../error';
|
|
8
8
|
|
|
9
9
|
/** @public */
|
|
10
10
|
export interface ValidateCollectionOptions extends CommandOperationOptions {
|
|
@@ -40,13 +40,14 @@ export class ValidateCollectionOperation extends CommandOperation<Document> {
|
|
|
40
40
|
super.executeCommand(server, session, this.command, (err, doc) => {
|
|
41
41
|
if (err != null) return callback(err);
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
if (doc.
|
|
45
|
-
|
|
43
|
+
// TODO(NODE-3483): Replace these with MongoUnexpectedServerResponseError
|
|
44
|
+
if (doc.ok === 0) return callback(new MongoRuntimeError('Error with validate command'));
|
|
45
|
+
if (doc.result != null && typeof doc.result !== 'string')
|
|
46
|
+
return callback(new MongoRuntimeError('Error with validation data'));
|
|
46
47
|
if (doc.result != null && doc.result.match(/exception|corrupt/) != null)
|
|
47
|
-
return callback(new
|
|
48
|
+
return callback(new MongoRuntimeError(`Invalid collection ${collectionName}`));
|
|
48
49
|
if (doc.valid != null && !doc.valid)
|
|
49
|
-
return callback(new
|
|
50
|
+
return callback(new MongoRuntimeError(`Invalid collection ${collectionName}`));
|
|
50
51
|
|
|
51
52
|
return callback(undefined, doc);
|
|
52
53
|
});
|
package/src/promise_provider.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MongoInvalidArgumentError } from './error';
|
|
2
2
|
|
|
3
3
|
/** @internal */
|
|
4
4
|
const kPromise = Symbol('promise');
|
|
@@ -19,7 +19,7 @@ export class PromiseProvider {
|
|
|
19
19
|
/** Validates the passed in promise library */
|
|
20
20
|
static validate(lib: unknown): lib is PromiseConstructor {
|
|
21
21
|
if (typeof lib !== 'function')
|
|
22
|
-
throw new
|
|
22
|
+
throw new MongoInvalidArgumentError(`Promise must be a function, got ${lib}`);
|
|
23
23
|
return !!lib;
|
|
24
24
|
}
|
|
25
25
|
|
package/src/read_preference.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TagSet } from './sdam/server_description';
|
|
2
2
|
import type { Document } from './bson';
|
|
3
3
|
import type { ClientSession } from './sessions';
|
|
4
|
-
import {
|
|
4
|
+
import { MongoInvalidArgumentError } from './error';
|
|
5
5
|
|
|
6
6
|
/** @public */
|
|
7
7
|
export type ReadPreferenceLike = ReadPreference | ReadPreferenceMode;
|
|
@@ -84,13 +84,13 @@ export class ReadPreference {
|
|
|
84
84
|
*/
|
|
85
85
|
constructor(mode: ReadPreferenceMode, tags?: TagSet[], options?: ReadPreferenceOptions) {
|
|
86
86
|
if (!ReadPreference.isValid(mode)) {
|
|
87
|
-
throw new
|
|
87
|
+
throw new MongoInvalidArgumentError(`Invalid read preference mode ${JSON.stringify(mode)}`);
|
|
88
88
|
}
|
|
89
|
-
if (options
|
|
89
|
+
if (options == null && typeof tags === 'object' && !Array.isArray(tags)) {
|
|
90
90
|
options = tags;
|
|
91
91
|
tags = undefined;
|
|
92
92
|
} else if (tags && !Array.isArray(tags)) {
|
|
93
|
-
throw new
|
|
93
|
+
throw new MongoInvalidArgumentError('ReadPreference tags must be an array');
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
this.mode = mode;
|
|
@@ -102,7 +102,7 @@ export class ReadPreference {
|
|
|
102
102
|
options = options ?? {};
|
|
103
103
|
if (options.maxStalenessSeconds != null) {
|
|
104
104
|
if (options.maxStalenessSeconds <= 0) {
|
|
105
|
-
throw new
|
|
105
|
+
throw new MongoInvalidArgumentError('maxStalenessSeconds must be a positive integer');
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
this.maxStalenessSeconds = options.maxStalenessSeconds;
|
|
@@ -114,17 +114,19 @@ export class ReadPreference {
|
|
|
114
114
|
|
|
115
115
|
if (this.mode === ReadPreference.PRIMARY) {
|
|
116
116
|
if (this.tags && Array.isArray(this.tags) && this.tags.length > 0) {
|
|
117
|
-
throw new
|
|
117
|
+
throw new MongoInvalidArgumentError('Primary read preference cannot be combined with tags');
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
if (this.maxStalenessSeconds) {
|
|
121
|
-
throw new
|
|
121
|
+
throw new MongoInvalidArgumentError(
|
|
122
122
|
'Primary read preference cannot be combined with maxStalenessSeconds'
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
if (this.hedge) {
|
|
127
|
-
throw new
|
|
127
|
+
throw new MongoInvalidArgumentError(
|
|
128
|
+
'Primary read preference cannot be combined with hedge'
|
|
129
|
+
);
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
}
|
|
@@ -193,7 +195,7 @@ export class ReadPreference {
|
|
|
193
195
|
});
|
|
194
196
|
}
|
|
195
197
|
} else if (!(r instanceof ReadPreference)) {
|
|
196
|
-
throw new
|
|
198
|
+
throw new MongoInvalidArgumentError(`Invalid read preference: ${r}`);
|
|
197
199
|
}
|
|
198
200
|
|
|
199
201
|
return options;
|