mongodb 4.2.0 → 4.3.1
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 +2 -2
- package/lib/admin.js +3 -3
- package/lib/admin.js.map +1 -1
- package/lib/bson.js +16 -14
- package/lib/bson.js.map +1 -1
- package/lib/bulk/common.js +7 -7
- package/lib/bulk/common.js.map +1 -1
- package/lib/bulk/ordered.js +1 -1
- package/lib/bulk/ordered.js.map +1 -1
- package/lib/bulk/unordered.js +1 -1
- package/lib/bulk/unordered.js.map +1 -1
- package/lib/change_stream.js +6 -7
- package/lib/change_stream.js.map +1 -1
- package/lib/cmap/auth/auth_provider.js.map +1 -1
- package/lib/cmap/auth/gssapi.js +3 -3
- package/lib/cmap/auth/gssapi.js.map +1 -1
- package/lib/cmap/auth/mongo_credentials.js +24 -26
- 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 +6 -6
- 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/providers.js +21 -0
- package/lib/cmap/auth/providers.js.map +1 -0
- package/lib/cmap/auth/scram.js +4 -4
- package/lib/cmap/auth/scram.js.map +1 -1
- package/lib/cmap/auth/x509.js +1 -1
- package/lib/cmap/auth/x509.js.map +1 -1
- package/lib/cmap/command_monitoring_events.js +3 -2
- package/lib/cmap/command_monitoring_events.js.map +1 -1
- package/lib/cmap/commands.js +20 -11
- package/lib/cmap/commands.js.map +1 -1
- package/lib/cmap/connect.js +119 -31
- package/lib/cmap/connect.js.map +1 -1
- package/lib/cmap/connection.js +36 -35
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +19 -30
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/message_stream.js +3 -3
- package/lib/cmap/message_stream.js.map +1 -1
- package/lib/cmap/stream_description.js +4 -4
- package/lib/cmap/stream_description.js.map +1 -1
- package/lib/cmap/wire_protocol/compression.js +2 -1
- package/lib/cmap/wire_protocol/compression.js.map +1 -1
- package/lib/cmap/wire_protocol/shared.js +4 -3
- package/lib/cmap/wire_protocol/shared.js.map +1 -1
- package/lib/collection.js +45 -47
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +48 -23
- package/lib/connection_string.js.map +1 -1
- package/lib/constants.js +113 -1
- package/lib/constants.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +10 -7
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/aggregation_cursor.js +1 -1
- package/lib/cursor/aggregation_cursor.js.map +1 -1
- package/lib/cursor/find_cursor.js +1 -1
- package/lib/cursor/find_cursor.js.map +1 -1
- package/lib/db.js +23 -13
- package/lib/db.js.map +1 -1
- package/lib/deps.js +0 -1
- package/lib/deps.js.map +1 -1
- package/lib/encrypter.js +12 -4
- package/lib/encrypter.js.map +1 -1
- package/lib/error.js +47 -24
- package/lib/error.js.map +1 -1
- package/lib/gridfs/download.js +1 -1
- package/lib/gridfs/download.js.map +1 -1
- package/lib/gridfs/index.js +3 -3
- package/lib/gridfs/index.js.map +1 -1
- package/lib/gridfs/upload.js +3 -2
- package/lib/gridfs/upload.js.map +1 -1
- package/lib/index.js +81 -81
- package/lib/index.js.map +1 -1
- package/lib/logger.js +1 -1
- package/lib/logger.js.map +1 -1
- package/lib/mongo_client.js +5 -5
- package/lib/mongo_client.js.map +1 -1
- package/lib/mongo_types.js.map +1 -1
- package/lib/operations/add_user.js +3 -3
- package/lib/operations/add_user.js.map +1 -1
- package/lib/operations/aggregate.js +1 -1
- package/lib/operations/aggregate.js.map +1 -1
- package/lib/operations/bulk_write.js.map +1 -1
- package/lib/operations/collections.js +1 -1
- package/lib/operations/collections.js.map +1 -1
- package/lib/operations/command.js +5 -6
- package/lib/operations/command.js.map +1 -1
- package/lib/operations/common_functions.js.map +1 -1
- package/lib/operations/connect.js +4 -13
- 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.map +1 -1
- package/lib/operations/create_collection.js +3 -2
- package/lib/operations/create_collection.js.map +1 -1
- package/lib/operations/delete.js +3 -3
- package/lib/operations/delete.js.map +1 -1
- package/lib/operations/distinct.js +3 -3
- package/lib/operations/distinct.js.map +1 -1
- package/lib/operations/drop.js +1 -1
- package/lib/operations/drop.js.map +1 -1
- package/lib/operations/estimated_document_count.js +2 -2
- package/lib/operations/estimated_document_count.js.map +1 -1
- package/lib/operations/eval.js +2 -2
- package/lib/operations/eval.js.map +1 -1
- package/lib/operations/execute_operation.js +15 -9
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find.js +5 -5
- package/lib/operations/find.js.map +1 -1
- package/lib/operations/find_and_modify.js +2 -2
- package/lib/operations/find_and_modify.js.map +1 -1
- package/lib/operations/get_more.js +28 -0
- package/lib/operations/get_more.js.map +1 -0
- package/lib/operations/indexes.js +4 -4
- package/lib/operations/indexes.js.map +1 -1
- package/lib/operations/insert.js +3 -3
- package/lib/operations/insert.js.map +1 -1
- package/lib/operations/is_capped.js +1 -1
- package/lib/operations/is_capped.js.map +1 -1
- package/lib/operations/list_collections.js +3 -3
- package/lib/operations/list_collections.js.map +1 -1
- package/lib/operations/list_databases.js +1 -1
- package/lib/operations/list_databases.js.map +1 -1
- package/lib/operations/map_reduce.js +4 -3
- package/lib/operations/map_reduce.js.map +1 -1
- package/lib/operations/operation.js +3 -2
- package/lib/operations/operation.js.map +1 -1
- package/lib/operations/options_operation.js +1 -1
- package/lib/operations/options_operation.js.map +1 -1
- package/lib/operations/profiling_level.js +1 -1
- package/lib/operations/profiling_level.js.map +1 -1
- package/lib/operations/remove_user.js +1 -1
- package/lib/operations/remove_user.js.map +1 -1
- package/lib/operations/rename.js +3 -3
- package/lib/operations/rename.js.map +1 -1
- package/lib/operations/run_command.js +1 -1
- package/lib/operations/run_command.js.map +1 -1
- package/lib/operations/set_profiling_level.js +2 -2
- package/lib/operations/set_profiling_level.js.map +1 -1
- package/lib/operations/stats.js +1 -1
- package/lib/operations/stats.js.map +1 -1
- package/lib/operations/update.js +2 -2
- package/lib/operations/update.js.map +1 -1
- package/lib/operations/validate_collection.js +1 -1
- package/lib/operations/validate_collection.js.map +1 -1
- package/lib/read_preference.js +15 -5
- package/lib/read_preference.js.map +1 -1
- package/lib/sdam/events.js +4 -4
- package/lib/sdam/monitor.js +19 -18
- package/lib/sdam/monitor.js.map +1 -1
- package/lib/sdam/server.js +24 -31
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/server_description.js +38 -38
- package/lib/sdam/server_description.js.map +1 -1
- package/lib/sdam/server_selection.js +19 -3
- package/lib/sdam/server_selection.js.map +1 -1
- package/lib/sdam/srv_polling.js +2 -2
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sdam/topology.js +32 -62
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sdam/topology_description.js +3 -3
- package/lib/sdam/topology_description.js.map +1 -1
- package/lib/sessions.js +13 -28
- package/lib/sessions.js.map +1 -1
- package/lib/transactions.js +1 -1
- package/lib/transactions.js.map +1 -1
- package/lib/utils.js +46 -15
- package/lib/utils.js.map +1 -1
- package/mongodb.d.ts +145 -61
- package/mongodb.ts34.d.ts +173 -60
- package/package.json +29 -28
- package/src/admin.ts +9 -9
- package/src/bson.ts +26 -17
- package/src/bulk/common.ts +22 -23
- package/src/bulk/ordered.ts +4 -4
- package/src/bulk/unordered.ts +5 -5
- package/src/change_stream.ts +31 -28
- package/src/cmap/auth/auth_provider.ts +3 -3
- package/src/cmap/auth/gssapi.ts +8 -8
- package/src/cmap/auth/mongo_credentials.ts +11 -15
- package/src/cmap/auth/mongocr.ts +3 -2
- package/src/cmap/auth/mongodb_aws.ts +10 -11
- package/src/cmap/auth/plain.ts +1 -1
- package/src/cmap/auth/providers.ts +21 -0
- package/src/cmap/auth/scram.ts +9 -9
- package/src/cmap/auth/x509.ts +3 -3
- package/src/cmap/command_monitoring_events.ts +4 -3
- package/src/cmap/commands.ts +30 -19
- package/src/cmap/connect.ts +161 -37
- package/src/cmap/connection.ts +83 -63
- package/src/cmap/connection_pool.ts +39 -39
- package/src/cmap/connection_pool_events.ts +1 -1
- package/src/cmap/message_stream.ts +9 -8
- package/src/cmap/stream_description.ts +5 -5
- package/src/cmap/wire_protocol/compression.ts +4 -3
- package/src/cmap/wire_protocol/shared.ts +10 -9
- package/src/collection.ts +114 -95
- package/src/connection_string.ts +66 -29
- package/src/constants.ts +122 -0
- package/src/cursor/abstract_cursor.ts +21 -22
- package/src/cursor/aggregation_cursor.ts +6 -6
- package/src/cursor/find_cursor.ts +2 -2
- package/src/db.ts +44 -33
- package/src/deps.ts +3 -1
- package/src/encrypter.ts +12 -3
- package/src/error.ts +52 -24
- package/src/gridfs/download.ts +10 -8
- package/src/gridfs/index.ts +11 -11
- package/src/gridfs/upload.ts +13 -10
- package/src/index.ts +204 -199
- package/src/logger.ts +2 -1
- package/src/mongo_client.ts +46 -32
- package/src/mongo_types.ts +119 -21
- package/src/operations/add_user.ts +7 -6
- package/src/operations/aggregate.ts +5 -5
- package/src/operations/bulk_write.ts +5 -5
- package/src/operations/collections.ts +2 -2
- package/src/operations/command.ts +15 -9
- package/src/operations/common_functions.ts +4 -4
- package/src/operations/connect.ts +4 -14
- package/src/operations/count.ts +4 -4
- package/src/operations/count_documents.ts +3 -3
- package/src/operations/create_collection.ts +7 -6
- package/src/operations/delete.ts +5 -5
- package/src/operations/distinct.ts +4 -4
- package/src/operations/drop.ts +4 -4
- package/src/operations/estimated_document_count.ts +5 -5
- package/src/operations/eval.ts +5 -5
- package/src/operations/execute_operation.ts +21 -13
- package/src/operations/find.ts +14 -14
- package/src/operations/find_and_modify.ts +7 -7
- package/src/operations/get_more.ts +49 -0
- package/src/operations/indexes.ts +16 -16
- package/src/operations/insert.ts +9 -9
- package/src/operations/is_capped.ts +3 -3
- package/src/operations/list_collections.ts +6 -6
- package/src/operations/list_databases.ts +4 -4
- package/src/operations/map_reduce.ts +10 -9
- package/src/operations/operation.ts +5 -4
- package/src/operations/options_operation.ts +3 -3
- package/src/operations/profiling_level.ts +4 -4
- package/src/operations/remove_user.ts +4 -4
- package/src/operations/rename.ts +6 -6
- package/src/operations/run_command.ts +3 -3
- package/src/operations/set_profiling_level.ts +6 -5
- package/src/operations/stats.ts +4 -4
- package/src/operations/update.ts +10 -10
- package/src/operations/validate_collection.ts +4 -4
- package/src/read_preference.ts +18 -7
- package/src/sdam/common.ts +2 -2
- package/src/sdam/events.ts +5 -5
- package/src/sdam/monitor.ts +29 -32
- package/src/sdam/server.ts +64 -62
- package/src/sdam/server_description.ts +41 -48
- package/src/sdam/server_selection.ts +21 -3
- package/src/sdam/srv_polling.ts +3 -2
- package/src/sdam/topology.ts +71 -89
- package/src/sdam/topology_description.ts +5 -5
- package/src/sessions.ts +31 -48
- package/src/transactions.ts +4 -4
- package/src/utils.ts +69 -33
- package/lib/cmap/auth/defaultAuthProviders.js +0 -30
- package/lib/cmap/auth/defaultAuthProviders.js.map +0 -1
- package/src/cmap/auth/defaultAuthProviders.ts +0 -32
package/src/operations/find.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Aspect, defineAspects, Hint } from './operation';
|
|
2
|
-
import {
|
|
3
|
-
maxWireVersion,
|
|
4
|
-
MongoDBNamespace,
|
|
5
|
-
Callback,
|
|
6
|
-
normalizeHintField,
|
|
7
|
-
decorateWithExplain
|
|
8
|
-
} from '../utils';
|
|
9
|
-
import { MongoInvalidArgumentError, MongoCompatibilityError } from '../error';
|
|
10
1
|
import type { Document } from '../bson';
|
|
11
|
-
import type { Server } from '../sdam/server';
|
|
12
|
-
import type { Collection } from '../collection';
|
|
13
|
-
import { CommandOperation, CommandOperationOptions, CollationOptions } from './command';
|
|
14
|
-
import { Sort, formatSort } from '../sort';
|
|
15
2
|
import { isSharded } from '../cmap/wire_protocol/shared';
|
|
3
|
+
import type { Collection } from '../collection';
|
|
4
|
+
import { MongoCompatibilityError, MongoInvalidArgumentError } from '../error';
|
|
16
5
|
import { ReadConcern } from '../read_concern';
|
|
6
|
+
import type { Server } from '../sdam/server';
|
|
17
7
|
import type { ClientSession } from '../sessions';
|
|
8
|
+
import { formatSort, Sort } from '../sort';
|
|
9
|
+
import {
|
|
10
|
+
Callback,
|
|
11
|
+
decorateWithExplain,
|
|
12
|
+
maxWireVersion,
|
|
13
|
+
MongoDBNamespace,
|
|
14
|
+
normalizeHintField
|
|
15
|
+
} from '../utils';
|
|
16
|
+
import { CollationOptions, CommandOperation, CommandOperationOptions } from './command';
|
|
17
|
+
import { Aspect, defineAspects, Hint } from './operation';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @public
|
|
@@ -36,7 +36,7 @@ export interface FindOptions<TSchema extends Document = Document> extends Comman
|
|
|
36
36
|
timeout?: boolean;
|
|
37
37
|
/** Specify if the cursor is tailable. */
|
|
38
38
|
tailable?: boolean;
|
|
39
|
-
/** Specify if the cursor is a
|
|
39
|
+
/** Specify if the cursor is a tailable-await cursor. Requires `tailable` to be true */
|
|
40
40
|
awaitData?: boolean;
|
|
41
41
|
/** Set the batchSize for the getMoreCommand when iterating over the query results. */
|
|
42
42
|
batchSize?: number;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ReadPreference } from '../read_preference';
|
|
2
|
-
import { maxWireVersion, decorateWithCollation, hasAtomicOperators, Callback } from '../utils';
|
|
3
|
-
import { MongoInvalidArgumentError, MongoCompatibilityError } from '../error';
|
|
4
|
-
import { CommandOperation, CommandOperationOptions } from './command';
|
|
5
|
-
import { defineAspects, Aspect } from './operation';
|
|
6
1
|
import type { Document } from '../bson';
|
|
7
|
-
import type { Server } from '../sdam/server';
|
|
8
2
|
import type { Collection } from '../collection';
|
|
9
|
-
import {
|
|
3
|
+
import { MongoCompatibilityError, MongoInvalidArgumentError } from '../error';
|
|
4
|
+
import { ReadPreference } from '../read_preference';
|
|
5
|
+
import type { Server } from '../sdam/server';
|
|
10
6
|
import type { ClientSession } from '../sessions';
|
|
7
|
+
import { formatSort, Sort, SortForCmd } from '../sort';
|
|
8
|
+
import { Callback, decorateWithCollation, hasAtomicOperators, maxWireVersion } from '../utils';
|
|
11
9
|
import type { WriteConcern, WriteConcernSettings } from '../write_concern';
|
|
10
|
+
import { CommandOperation, CommandOperationOptions } from './command';
|
|
11
|
+
import { Aspect, defineAspects } from './operation';
|
|
12
12
|
|
|
13
13
|
/** @public */
|
|
14
14
|
export const ReturnDocument = Object.freeze({
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Document, Long } from '../bson';
|
|
2
|
+
import { MongoRuntimeError } from '../error';
|
|
3
|
+
import type { Server } from '../sdam/server';
|
|
4
|
+
import type { ClientSession } from '../sessions';
|
|
5
|
+
import type { Callback, MongoDBNamespace } from '../utils';
|
|
6
|
+
import { AbstractOperation, Aspect, defineAspects, OperationOptions } from './operation';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
|
+
export interface GetMoreOptions extends OperationOptions {
|
|
13
|
+
/** Set the batchSize for the getMoreCommand when iterating over the query results. */
|
|
14
|
+
batchSize?: number;
|
|
15
|
+
/** You can put a $comment field on a query to make looking in the profiler logs simpler. */
|
|
16
|
+
comment?: string | Document;
|
|
17
|
+
/** Number of milliseconds to wait before aborting the query. */
|
|
18
|
+
maxTimeMS?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** @internal */
|
|
22
|
+
export class GetMoreOperation extends AbstractOperation {
|
|
23
|
+
cursorId: Long;
|
|
24
|
+
options: GetMoreOptions;
|
|
25
|
+
server: Server;
|
|
26
|
+
|
|
27
|
+
constructor(ns: MongoDBNamespace, cursorId: Long, server: Server, options: GetMoreOptions = {}) {
|
|
28
|
+
super(options);
|
|
29
|
+
this.options = options;
|
|
30
|
+
this.ns = ns;
|
|
31
|
+
this.cursorId = cursorId;
|
|
32
|
+
this.server = server;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Although there is a server already associated with the get more operation, the signature
|
|
37
|
+
* for execute passes a server so we will just use that one.
|
|
38
|
+
*/
|
|
39
|
+
execute(server: Server, session: ClientSession, callback: Callback<Document>): void {
|
|
40
|
+
if (server !== this.server) {
|
|
41
|
+
return callback(
|
|
42
|
+
new MongoRuntimeError('Getmore must run on the same server operation began on')
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
server.getMore(this.ns, this.cursorId, this.options, callback);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
defineAspects(GetMoreOperation, [Aspect.READ_OPERATION, Aspect.CURSOR_ITERATING]);
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { Document } from '../bson';
|
|
2
|
+
import type { Collection } from '../collection';
|
|
3
|
+
import { AbstractCursor } from '../cursor/abstract_cursor';
|
|
4
|
+
import type { Db } from '../db';
|
|
5
|
+
import { MongoCompatibilityError, MONGODB_ERROR_CODES, MongoServerError } from '../error';
|
|
6
|
+
import type { OneOrMore } from '../mongo_types';
|
|
7
|
+
import { ReadPreference } from '../read_preference';
|
|
8
|
+
import type { Server } from '../sdam/server';
|
|
9
|
+
import type { ClientSession } from '../sessions';
|
|
4
10
|
import {
|
|
11
|
+
Callback,
|
|
12
|
+
getTopology,
|
|
5
13
|
maxWireVersion,
|
|
6
|
-
parseIndexOptions,
|
|
7
14
|
MongoDBNamespace,
|
|
8
|
-
|
|
9
|
-
getTopology
|
|
15
|
+
parseIndexOptions
|
|
10
16
|
} from '../utils';
|
|
11
17
|
import {
|
|
18
|
+
CollationOptions,
|
|
12
19
|
CommandOperation,
|
|
13
20
|
CommandOperationOptions,
|
|
14
|
-
OperationParent
|
|
15
|
-
CollationOptions
|
|
21
|
+
OperationParent
|
|
16
22
|
} from './command';
|
|
17
|
-
import {
|
|
18
|
-
import type { Server } from '../sdam/server';
|
|
19
|
-
import type { Document } from '../bson';
|
|
20
|
-
import type { Collection } from '../collection';
|
|
21
|
-
import type { Db } from '../db';
|
|
22
|
-
import { AbstractCursor } from '../cursor/abstract_cursor';
|
|
23
|
-
import type { ClientSession } from '../sessions';
|
|
23
|
+
import { indexInformation, IndexInformationOptions } from './common_functions';
|
|
24
24
|
import { executeOperation, ExecutionResult } from './execute_operation';
|
|
25
|
-
import
|
|
25
|
+
import { AbstractOperation, Aspect, defineAspects } from './operation';
|
|
26
26
|
|
|
27
27
|
const LIST_INDEXES_WIRE_VERSION = 3;
|
|
28
28
|
const VALID_INDEX_OPTIONS = new Set([
|
package/src/operations/insert.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { MongoServerError, MongoInvalidArgumentError } from '../error';
|
|
2
|
-
import { defineAspects, Aspect, AbstractOperation } from './operation';
|
|
3
|
-
import { CommandOperation, CommandOperationOptions } from './command';
|
|
4
|
-
import { prepareDocs } from './common_functions';
|
|
5
|
-
import type { Callback, MongoDBNamespace } from '../utils';
|
|
6
|
-
import type { Server } from '../sdam/server';
|
|
7
|
-
import type { Collection } from '../collection';
|
|
8
1
|
import type { Document } from '../bson';
|
|
9
2
|
import type { BulkWriteOptions } from '../bulk/common';
|
|
10
|
-
import {
|
|
3
|
+
import type { Collection } from '../collection';
|
|
4
|
+
import { MongoInvalidArgumentError, MongoServerError } from '../error';
|
|
5
|
+
import type { InferIdType } from '../mongo_types';
|
|
6
|
+
import type { Server } from '../sdam/server';
|
|
11
7
|
import type { ClientSession } from '../sessions';
|
|
8
|
+
import type { Callback, MongoDBNamespace } from '../utils';
|
|
9
|
+
import { WriteConcern } from '../write_concern';
|
|
12
10
|
import { BulkWriteOperation } from './bulk_write';
|
|
13
|
-
import
|
|
11
|
+
import { CommandOperation, CommandOperationOptions } from './command';
|
|
12
|
+
import { prepareDocs } from './common_functions';
|
|
13
|
+
import { AbstractOperation, Aspect, defineAspects } from './operation';
|
|
14
14
|
|
|
15
15
|
/** @internal */
|
|
16
16
|
export class InsertOperation extends CommandOperation<Document> {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Callback } from '../utils';
|
|
2
1
|
import type { Collection } from '../collection';
|
|
3
|
-
import {
|
|
2
|
+
import { MongoAPIError } from '../error';
|
|
4
3
|
import type { Server } from '../sdam/server';
|
|
5
4
|
import type { ClientSession } from '../sessions';
|
|
6
|
-
import {
|
|
5
|
+
import type { Callback } from '../utils';
|
|
6
|
+
import { AbstractOperation, OperationOptions } from './operation';
|
|
7
7
|
|
|
8
8
|
/** @internal */
|
|
9
9
|
export class IsCappedOperation extends AbstractOperation<boolean> {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { CommandOperation, CommandOperationOptions } from './command';
|
|
2
|
-
import { Aspect, defineAspects } from './operation';
|
|
3
|
-
import { maxWireVersion, Callback, getTopology, MongoDBNamespace } from '../utils';
|
|
4
|
-
import * as CONSTANTS from '../constants';
|
|
5
1
|
import type { Binary, Document } from '../bson';
|
|
6
|
-
import
|
|
7
|
-
import type { Db } from '../db';
|
|
2
|
+
import * as CONSTANTS from '../constants';
|
|
8
3
|
import { AbstractCursor } from '../cursor/abstract_cursor';
|
|
4
|
+
import type { Db } from '../db';
|
|
5
|
+
import type { Server } from '../sdam/server';
|
|
9
6
|
import type { ClientSession } from '../sessions';
|
|
7
|
+
import { Callback, getTopology, maxWireVersion, MongoDBNamespace } from '../utils';
|
|
8
|
+
import { CommandOperation, CommandOperationOptions } from './command';
|
|
10
9
|
import { executeOperation, ExecutionResult } from './execute_operation';
|
|
10
|
+
import { Aspect, defineAspects } from './operation';
|
|
11
11
|
|
|
12
12
|
const LIST_COLLECTIONS_WIRE_VERSION = 3;
|
|
13
13
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CommandOperation, CommandOperationOptions } from './command';
|
|
2
|
-
import { Aspect, defineAspects } from './operation';
|
|
3
|
-
import { MongoDBNamespace, Callback } from '../utils';
|
|
4
1
|
import type { Document } from '../bson';
|
|
5
|
-
import type { Server } from '../sdam/server';
|
|
6
2
|
import type { Db } from '../db';
|
|
3
|
+
import type { Server } from '../sdam/server';
|
|
7
4
|
import type { ClientSession } from '../sessions';
|
|
5
|
+
import { Callback, MongoDBNamespace } from '../utils';
|
|
6
|
+
import { CommandOperation, CommandOperationOptions } from './command';
|
|
7
|
+
import { Aspect, defineAspects } from './operation';
|
|
8
8
|
|
|
9
9
|
/** @public */
|
|
10
10
|
export interface ListDatabasesResult {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
+
import type { ObjectId } from '../bson';
|
|
1
2
|
import { Code, Document } from '../bson';
|
|
3
|
+
import type { Collection } from '../collection';
|
|
4
|
+
import { Db } from '../db';
|
|
5
|
+
import { MongoCompatibilityError, MongoServerError } from '../error';
|
|
6
|
+
import { ReadPreference, ReadPreferenceMode } from '../read_preference';
|
|
7
|
+
import type { Server } from '../sdam/server';
|
|
8
|
+
import type { ClientSession } from '../sessions';
|
|
9
|
+
import type { Sort } from '../sort';
|
|
2
10
|
import {
|
|
3
11
|
applyWriteConcern,
|
|
12
|
+
Callback,
|
|
4
13
|
decorateWithCollation,
|
|
5
14
|
decorateWithReadConcern,
|
|
6
15
|
isObject,
|
|
7
|
-
Callback,
|
|
8
16
|
maxWireVersion
|
|
9
17
|
} from '../utils';
|
|
10
|
-
import { ReadPreference, ReadPreferenceMode } from '../read_preference';
|
|
11
18
|
import { CommandOperation, CommandOperationOptions } from './command';
|
|
12
|
-
import type { Server } from '../sdam/server';
|
|
13
|
-
import type { Collection } from '../collection';
|
|
14
|
-
import type { Sort } from '../sort';
|
|
15
|
-
import { MongoServerError, MongoCompatibilityError } from '../error';
|
|
16
|
-
import type { ObjectId } from '../bson';
|
|
17
19
|
import { Aspect, defineAspects } from './operation';
|
|
18
|
-
import type { ClientSession } from '../sessions';
|
|
19
|
-
import { Db } from '../db';
|
|
20
20
|
|
|
21
21
|
const exclusionList = [
|
|
22
22
|
'explain',
|
|
@@ -33,6 +33,7 @@ const exclusionList = [
|
|
|
33
33
|
'bsonRegExp',
|
|
34
34
|
'serializeFunctions',
|
|
35
35
|
'ignoreUndefined',
|
|
36
|
+
'enableUtf8Validation',
|
|
36
37
|
'scope' // this option is reformatted thus exclude the original
|
|
37
38
|
];
|
|
38
39
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { BSONSerializeOptions, Document, resolveBSONOptions } from '../bson';
|
|
1
2
|
import { ReadPreference, ReadPreferenceLike } from '../read_preference';
|
|
2
|
-
import type { ClientSession } from '../sessions';
|
|
3
|
-
import { Document, BSONSerializeOptions, resolveBSONOptions } from '../bson';
|
|
4
|
-
import type { MongoDBNamespace, Callback } from '../utils';
|
|
5
3
|
import type { Server } from '../sdam/server';
|
|
4
|
+
import type { ClientSession } from '../sessions';
|
|
5
|
+
import type { Callback, MongoDBNamespace } from '../utils';
|
|
6
6
|
|
|
7
7
|
export const Aspect = {
|
|
8
8
|
READ_OPERATION: Symbol('READ_OPERATION'),
|
|
@@ -10,7 +10,8 @@ export const Aspect = {
|
|
|
10
10
|
RETRYABLE: Symbol('RETRYABLE'),
|
|
11
11
|
EXPLAINABLE: Symbol('EXPLAINABLE'),
|
|
12
12
|
SKIP_COLLATION: Symbol('SKIP_COLLATION'),
|
|
13
|
-
CURSOR_CREATING: Symbol('CURSOR_CREATING')
|
|
13
|
+
CURSOR_CREATING: Symbol('CURSOR_CREATING'),
|
|
14
|
+
CURSOR_ITERATING: Symbol('CURSOR_ITERATING')
|
|
14
15
|
} as const;
|
|
15
16
|
|
|
16
17
|
/** @public */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AbstractOperation, OperationOptions } from './operation';
|
|
2
|
-
import { MongoAPIError } from '../error';
|
|
3
|
-
import type { Callback } from '../utils';
|
|
4
1
|
import type { Document } from '../bson';
|
|
5
2
|
import type { Collection } from '../collection';
|
|
3
|
+
import { MongoAPIError } from '../error';
|
|
6
4
|
import type { Server } from '../sdam/server';
|
|
7
5
|
import type { ClientSession } from '../sessions';
|
|
6
|
+
import type { Callback } from '../utils';
|
|
7
|
+
import { AbstractOperation, OperationOptions } from './operation';
|
|
8
8
|
|
|
9
9
|
/** @internal */
|
|
10
10
|
export class OptionsOperation extends AbstractOperation<Document> {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CommandOperation, CommandOperationOptions } from './command';
|
|
2
|
-
import type { Callback } from '../utils';
|
|
3
|
-
import type { Server } from '../sdam/server';
|
|
4
1
|
import type { Db } from '../db';
|
|
5
|
-
import type { ClientSession } from '../sessions';
|
|
6
2
|
import { MongoRuntimeError } from '../error';
|
|
3
|
+
import type { Server } from '../sdam/server';
|
|
4
|
+
import type { ClientSession } from '../sessions';
|
|
5
|
+
import type { Callback } from '../utils';
|
|
6
|
+
import { CommandOperation, CommandOperationOptions } from './command';
|
|
7
7
|
|
|
8
8
|
/** @public */
|
|
9
9
|
export type ProfilingLevelOptions = CommandOperationOptions;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Aspect, defineAspects } from './operation';
|
|
2
|
-
import { CommandOperation, CommandOperationOptions } from './command';
|
|
3
|
-
import type { Callback } from '../utils';
|
|
4
|
-
import type { Server } from '../sdam/server';
|
|
5
1
|
import type { Db } from '../db';
|
|
2
|
+
import type { Server } from '../sdam/server';
|
|
6
3
|
import type { ClientSession } from '../sessions';
|
|
4
|
+
import type { Callback } from '../utils';
|
|
5
|
+
import { CommandOperation, CommandOperationOptions } from './command';
|
|
6
|
+
import { Aspect, defineAspects } from './operation';
|
|
7
7
|
|
|
8
8
|
/** @public */
|
|
9
9
|
export type RemoveUserOptions = CommandOperationOptions;
|
package/src/operations/rename.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RunAdminCommandOperation } from './run_command';
|
|
3
|
-
import { defineAspects, Aspect } from './operation';
|
|
4
|
-
import type { Server } from '../sdam/server';
|
|
1
|
+
import type { Document } from '../bson';
|
|
5
2
|
import { Collection } from '../collection';
|
|
6
|
-
import type { CommandOperationOptions } from './command';
|
|
7
3
|
import { MongoServerError } from '../error';
|
|
4
|
+
import type { Server } from '../sdam/server';
|
|
8
5
|
import type { ClientSession } from '../sessions';
|
|
9
|
-
import
|
|
6
|
+
import { Callback, checkCollectionName } from '../utils';
|
|
7
|
+
import type { CommandOperationOptions } from './command';
|
|
8
|
+
import { Aspect, defineAspects } from './operation';
|
|
9
|
+
import { RunAdminCommandOperation } from './run_command';
|
|
10
10
|
|
|
11
11
|
/** @public */
|
|
12
12
|
export interface RenameOptions extends CommandOperationOptions {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CommandOperation, CommandOperationOptions, OperationParent } from './command';
|
|
2
|
-
import { MongoDBNamespace, Callback } from '../utils';
|
|
3
|
-
import type { Server } from '../sdam/server';
|
|
4
1
|
import type { Document } from '../bson';
|
|
2
|
+
import type { Server } from '../sdam/server';
|
|
5
3
|
import type { ClientSession } from '../sessions';
|
|
4
|
+
import { Callback, MongoDBNamespace } from '../utils';
|
|
5
|
+
import { CommandOperation, CommandOperationOptions, OperationParent } from './command';
|
|
6
6
|
|
|
7
7
|
/** @public */
|
|
8
8
|
export type RunCommandOptions = CommandOperationOptions;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { CommandOperation, CommandOperationOptions } from './command';
|
|
2
|
-
import type { Callback } from '../utils';
|
|
3
|
-
import { enumToString } from '../utils';
|
|
4
|
-
import type { Server } from '../sdam/server';
|
|
5
1
|
import type { Db } from '../db';
|
|
2
|
+
import { MongoInvalidArgumentError, MongoRuntimeError } from '../error';
|
|
3
|
+
import type { Server } from '../sdam/server';
|
|
6
4
|
import type { ClientSession } from '../sessions';
|
|
7
|
-
import {
|
|
5
|
+
import type { Callback } from '../utils';
|
|
6
|
+
import { enumToString } from '../utils';
|
|
7
|
+
import { CommandOperation, CommandOperationOptions } from './command';
|
|
8
|
+
|
|
8
9
|
const levelValues = new Set(['off', 'slow_only', 'all']);
|
|
9
10
|
|
|
10
11
|
/** @public */
|
package/src/operations/stats.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Aspect, defineAspects } from './operation';
|
|
2
|
-
import { CommandOperation, CommandOperationOptions } from './command';
|
|
3
|
-
import type { Callback } from '../utils';
|
|
4
1
|
import type { Document } from '../bson';
|
|
5
|
-
import type { Server } from '../sdam/server';
|
|
6
2
|
import type { Collection } from '../collection';
|
|
7
3
|
import type { Db } from '../db';
|
|
4
|
+
import type { Server } from '../sdam/server';
|
|
8
5
|
import type { ClientSession } from '../sessions';
|
|
6
|
+
import type { Callback } from '../utils';
|
|
7
|
+
import { CommandOperation, CommandOperationOptions } from './command';
|
|
8
|
+
import { Aspect, defineAspects } from './operation';
|
|
9
9
|
|
|
10
10
|
/** @public */
|
|
11
11
|
export interface CollStatsOptions extends CommandOperationOptions {
|
package/src/operations/update.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Document, ObjectId } from '../bson';
|
|
2
|
+
import type { Collection } from '../collection';
|
|
3
|
+
import { MongoCompatibilityError, MongoInvalidArgumentError, MongoServerError } from '../error';
|
|
4
|
+
import type { Server } from '../sdam/server';
|
|
5
|
+
import type { ClientSession } from '../sessions';
|
|
2
6
|
import {
|
|
3
|
-
hasAtomicOperators,
|
|
4
|
-
MongoDBNamespace,
|
|
5
7
|
Callback,
|
|
6
8
|
collationNotSupported,
|
|
7
|
-
|
|
9
|
+
hasAtomicOperators,
|
|
10
|
+
maxWireVersion,
|
|
11
|
+
MongoDBNamespace
|
|
8
12
|
} from '../utils';
|
|
9
|
-
import { CommandOperation, CommandOperationOptions
|
|
10
|
-
import
|
|
11
|
-
import type { Collection } from '../collection';
|
|
12
|
-
import type { ObjectId, Document } from '../bson';
|
|
13
|
-
import type { ClientSession } from '../sessions';
|
|
14
|
-
import { MongoServerError, MongoInvalidArgumentError, MongoCompatibilityError } from '../error';
|
|
13
|
+
import { CollationOptions, CommandOperation, CommandOperationOptions } from './command';
|
|
14
|
+
import { Aspect, defineAspects, Hint } from './operation';
|
|
15
15
|
|
|
16
16
|
/** @public */
|
|
17
17
|
export interface UpdateOptions extends CommandOperationOptions {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Callback } from '../utils';
|
|
1
|
+
import type { Admin } from '../admin';
|
|
3
2
|
import type { Document } from '../bson';
|
|
3
|
+
import { MongoRuntimeError } from '../error';
|
|
4
4
|
import type { Server } from '../sdam/server';
|
|
5
|
-
import type { Admin } from '../admin';
|
|
6
5
|
import type { ClientSession } from '../sessions';
|
|
7
|
-
import {
|
|
6
|
+
import type { Callback } from '../utils';
|
|
7
|
+
import { CommandOperation, CommandOperationOptions } from './command';
|
|
8
8
|
|
|
9
9
|
/** @public */
|
|
10
10
|
export interface ValidateCollectionOptions extends CommandOperationOptions {
|
package/src/read_preference.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { TagSet } from './sdam/server_description';
|
|
2
1
|
import type { Document } from './bson';
|
|
3
|
-
import type { ClientSession } from './sessions';
|
|
4
2
|
import { MongoInvalidArgumentError } from './error';
|
|
3
|
+
import type { TagSet } from './sdam/server_description';
|
|
4
|
+
import type { ClientSession } from './sessions';
|
|
5
5
|
|
|
6
6
|
/** @public */
|
|
7
7
|
export type ReadPreferenceLike = ReadPreference | ReadPreferenceMode;
|
|
@@ -156,7 +156,10 @@ export class ReadPreference {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
if (typeof readPreference === 'string') {
|
|
159
|
-
return new ReadPreference(readPreference as ReadPreferenceMode, readPreferenceTags
|
|
159
|
+
return new ReadPreference(readPreference as ReadPreferenceMode, readPreferenceTags, {
|
|
160
|
+
maxStalenessSeconds: options.maxStalenessSeconds,
|
|
161
|
+
hedge: options.hedge
|
|
162
|
+
});
|
|
160
163
|
} else if (!(readPreference instanceof ReadPreference) && typeof readPreference === 'object') {
|
|
161
164
|
const mode = readPreference.mode || readPreference.preference;
|
|
162
165
|
if (mode && typeof mode === 'string') {
|
|
@@ -229,19 +232,27 @@ export class ReadPreference {
|
|
|
229
232
|
}
|
|
230
233
|
|
|
231
234
|
/**
|
|
232
|
-
* Indicates that this readPreference needs the "
|
|
233
|
-
*
|
|
235
|
+
* Indicates that this readPreference needs the "secondaryOk" bit when sent over the wire
|
|
236
|
+
* @deprecated Use secondaryOk instead
|
|
234
237
|
* @see https://docs.mongodb.com/manual/reference/mongodb-wire-protocol/#op-query
|
|
235
238
|
*/
|
|
236
239
|
slaveOk(): boolean {
|
|
237
|
-
|
|
240
|
+
return this.secondaryOk();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Indicates that this readPreference needs the "SecondaryOk" bit when sent over the wire
|
|
245
|
+
* @see https://docs.mongodb.com/manual/reference/mongodb-wire-protocol/#op-query
|
|
246
|
+
*/
|
|
247
|
+
secondaryOk(): boolean {
|
|
248
|
+
const NEEDS_SECONDARYOK = new Set<string>([
|
|
238
249
|
ReadPreference.PRIMARY_PREFERRED,
|
|
239
250
|
ReadPreference.SECONDARY,
|
|
240
251
|
ReadPreference.SECONDARY_PREFERRED,
|
|
241
252
|
ReadPreference.NEAREST
|
|
242
253
|
]);
|
|
243
254
|
|
|
244
|
-
return
|
|
255
|
+
return NEEDS_SECONDARYOK.has(this.mode);
|
|
245
256
|
}
|
|
246
257
|
|
|
247
258
|
/**
|
package/src/sdam/common.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Topology } from './topology';
|
|
1
|
+
import type { Binary, Long, Timestamp } from '../bson';
|
|
3
2
|
import type { ClientSession } from '../sessions';
|
|
3
|
+
import type { Topology } from './topology';
|
|
4
4
|
|
|
5
5
|
// shared state names
|
|
6
6
|
export const STATE_CLOSING = 'closing';
|
package/src/sdam/events.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { Document } from '../bson';
|
|
1
2
|
import type { ServerDescription } from './server_description';
|
|
2
3
|
import type { TopologyDescription } from './topology_description';
|
|
3
|
-
import type { Document } from '../bson';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Emitted when server description changes, but does NOT include changes to the RTT.
|
|
@@ -123,8 +123,8 @@ export class TopologyClosedEvent {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
|
-
* Emitted when the server monitor’s
|
|
127
|
-
* the
|
|
126
|
+
* Emitted when the server monitor’s hello command is started - immediately before
|
|
127
|
+
* the hello command is serialized into raw BSON and written to the socket.
|
|
128
128
|
*
|
|
129
129
|
* @public
|
|
130
130
|
* @category Event
|
|
@@ -140,7 +140,7 @@ export class ServerHeartbeatStartedEvent {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
|
-
* Emitted when the server monitor’s
|
|
143
|
+
* Emitted when the server monitor’s hello succeeds.
|
|
144
144
|
* @public
|
|
145
145
|
* @category Event
|
|
146
146
|
*/
|
|
@@ -161,7 +161,7 @@ export class ServerHeartbeatSucceededEvent {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
|
-
* Emitted when the server monitor’s
|
|
164
|
+
* Emitted when the server monitor’s hello fails, either with an “ok: 0” or a socket exception.
|
|
165
165
|
* @public
|
|
166
166
|
* @category Event
|
|
167
167
|
*/
|