mongodb 4.1.4 → 4.3.0
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 +16 -15
- 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 +3 -4
- 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 +16 -18
- 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 +1 -1
- 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 +102 -15
- package/lib/cmap/connect.js.map +1 -1
- package/lib/cmap/connection.js +27 -26
- 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.map +1 -1
- package/lib/cmap/wire_protocol/constants.js +4 -4
- package/lib/cmap/wire_protocol/shared.js +4 -3
- package/lib/cmap/wire_protocol/shared.js.map +1 -1
- package/lib/collection.js +46 -47
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +106 -49
- package/lib/connection_string.js.map +1 -1
- package/lib/constants.js +108 -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 +2 -2
- package/lib/operations/add_user.js.map +1 -1
- package/lib/operations/aggregate.js +2 -3
- 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 +9 -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 +23 -7
- 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 +11 -6
- 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 +4 -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/monitor.js +4 -4
- package/lib/sdam/monitor.js.map +1 -1
- package/lib/sdam/server.js +31 -31
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/server_description.js +1 -1
- package/lib/sdam/server_description.js.map +1 -1
- package/lib/sdam/server_selection.js +38 -3
- package/lib/sdam/server_selection.js.map +1 -1
- package/lib/sdam/srv_polling.js +11 -11
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sdam/topology.js +40 -62
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sdam/topology_description.js +36 -14
- 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 +90 -23
- package/lib/utils.js.map +1 -1
- package/mongodb.d.ts +159 -65
- package/mongodb.ts34.d.ts +184 -65
- package/package.json +26 -24
- package/src/admin.ts +9 -9
- package/src/bson.ts +26 -17
- package/src/bulk/common.ts +26 -20
- package/src/bulk/ordered.ts +4 -4
- package/src/bulk/unordered.ts +5 -5
- package/src/change_stream.ts +35 -32
- package/src/cmap/auth/auth_provider.ts +3 -3
- package/src/cmap/auth/gssapi.ts +8 -8
- package/src/cmap/auth/mongo_credentials.ts +2 -6
- 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 +2 -2
- package/src/cmap/commands.ts +30 -19
- package/src/cmap/connect.ts +142 -22
- package/src/cmap/connection.ts +73 -52
- 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 +2 -2
- package/src/cmap/wire_protocol/constants.ts +4 -4
- package/src/cmap/wire_protocol/shared.ts +10 -9
- package/src/collection.ts +133 -106
- package/src/connection_string.ts +141 -60
- package/src/constants.ts +116 -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 +49 -39
- 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 +58 -32
- package/src/mongo_types.ts +98 -20
- package/src/operations/add_user.ts +6 -5
- package/src/operations/aggregate.ts +6 -7
- package/src/operations/bulk_write.ts +5 -5
- package/src/operations/collections.ts +2 -2
- package/src/operations/command.ts +19 -8
- 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 +8 -7
- 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 +30 -11
- 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 +18 -10
- package/src/operations/list_databases.ts +4 -4
- package/src/operations/map_reduce.ts +10 -9
- package/src/operations/operation.ts +8 -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 +1 -1
- package/src/sdam/monitor.ts +13 -14
- package/src/sdam/server.ts +71 -61
- package/src/sdam/server_description.ts +4 -4
- package/src/sdam/server_selection.ts +46 -3
- package/src/sdam/srv_polling.ts +15 -13
- package/src/sdam/topology.ts +89 -90
- package/src/sdam/topology_description.ts +39 -15
- package/src/sessions.ts +31 -48
- package/src/transactions.ts +6 -6
- package/src/utils.ts +123 -43
- 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/collection.ts
CHANGED
|
@@ -1,101 +1,104 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
normalizeHintField,
|
|
5
|
-
checkCollectionName,
|
|
6
|
-
MongoDBNamespace,
|
|
7
|
-
Callback,
|
|
8
|
-
getTopology
|
|
9
|
-
} from './utils';
|
|
10
|
-
import { Document, BSONSerializeOptions, resolveBSONOptions } from './bson';
|
|
11
|
-
import { MongoInvalidArgumentError } from './error';
|
|
12
|
-
import { UnorderedBulkOperation } from './bulk/unordered';
|
|
1
|
+
import { BSONSerializeOptions, Document, resolveBSONOptions } from './bson';
|
|
2
|
+
import type { AnyBulkWriteOperation, BulkWriteOptions, BulkWriteResult } from './bulk/common';
|
|
13
3
|
import { OrderedBulkOperation } from './bulk/ordered';
|
|
4
|
+
import { UnorderedBulkOperation } from './bulk/unordered';
|
|
14
5
|
import { ChangeStream, ChangeStreamOptions } from './change_stream';
|
|
15
|
-
import { WriteConcern, WriteConcernOptions } from './write_concern';
|
|
16
|
-
import { ReadConcern, ReadConcernLike } from './read_concern';
|
|
17
6
|
import { AggregationCursor } from './cursor/aggregation_cursor';
|
|
7
|
+
import { FindCursor } from './cursor/find_cursor';
|
|
8
|
+
import type { Db } from './db';
|
|
9
|
+
import { MongoInvalidArgumentError } from './error';
|
|
10
|
+
import type { Logger, LoggerOptions } from './logger';
|
|
11
|
+
import type { PkFactory } from './mongo_client';
|
|
12
|
+
import type {
|
|
13
|
+
Filter,
|
|
14
|
+
Flatten,
|
|
15
|
+
OptionalUnlessRequiredId,
|
|
16
|
+
TODO_NODE_3286,
|
|
17
|
+
UpdateFilter,
|
|
18
|
+
WithId,
|
|
19
|
+
WithoutId
|
|
20
|
+
} from './mongo_types';
|
|
18
21
|
import type { AggregateOptions } from './operations/aggregate';
|
|
19
22
|
import { BulkWriteOperation } from './operations/bulk_write';
|
|
23
|
+
import type { IndexInformationOptions } from './operations/common_functions';
|
|
24
|
+
import type { CountOptions } from './operations/count';
|
|
20
25
|
import { CountDocumentsOperation, CountDocumentsOptions } from './operations/count_documents';
|
|
21
26
|
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
IndexExistsOperation,
|
|
28
|
-
IndexInformationOperation,
|
|
29
|
-
CreateIndexesOptions,
|
|
30
|
-
DropIndexesOptions,
|
|
31
|
-
ListIndexesOptions,
|
|
32
|
-
IndexSpecification,
|
|
33
|
-
IndexDescription,
|
|
34
|
-
ListIndexesCursor
|
|
35
|
-
} from './operations/indexes';
|
|
27
|
+
DeleteManyOperation,
|
|
28
|
+
DeleteOneOperation,
|
|
29
|
+
DeleteOptions,
|
|
30
|
+
DeleteResult
|
|
31
|
+
} from './operations/delete';
|
|
36
32
|
import { DistinctOperation, DistinctOptions } from './operations/distinct';
|
|
37
33
|
import { DropCollectionOperation, DropCollectionOptions } from './operations/drop';
|
|
38
34
|
import {
|
|
39
35
|
EstimatedDocumentCountOperation,
|
|
40
36
|
EstimatedDocumentCountOptions
|
|
41
37
|
} from './operations/estimated_document_count';
|
|
38
|
+
import { executeOperation } from './operations/execute_operation';
|
|
42
39
|
import type { FindOptions } from './operations/find';
|
|
43
40
|
import {
|
|
44
41
|
FindOneAndDeleteOperation,
|
|
45
|
-
FindOneAndReplaceOperation,
|
|
46
|
-
FindOneAndUpdateOperation,
|
|
47
42
|
FindOneAndDeleteOptions,
|
|
43
|
+
FindOneAndReplaceOperation,
|
|
48
44
|
FindOneAndReplaceOptions,
|
|
45
|
+
FindOneAndUpdateOperation,
|
|
49
46
|
FindOneAndUpdateOptions
|
|
50
47
|
} from './operations/find_and_modify';
|
|
51
48
|
import {
|
|
49
|
+
CreateIndexesOperation,
|
|
50
|
+
CreateIndexesOptions,
|
|
51
|
+
CreateIndexOperation,
|
|
52
|
+
DropIndexesOperation,
|
|
53
|
+
DropIndexesOptions,
|
|
54
|
+
DropIndexOperation,
|
|
55
|
+
IndexDescription,
|
|
56
|
+
IndexesOperation,
|
|
57
|
+
IndexExistsOperation,
|
|
58
|
+
IndexInformationOperation,
|
|
59
|
+
IndexSpecification,
|
|
60
|
+
ListIndexesCursor,
|
|
61
|
+
ListIndexesOptions
|
|
62
|
+
} from './operations/indexes';
|
|
63
|
+
import {
|
|
64
|
+
InsertManyOperation,
|
|
65
|
+
InsertManyResult,
|
|
52
66
|
InsertOneOperation,
|
|
53
67
|
InsertOneOptions,
|
|
54
|
-
InsertOneResult
|
|
55
|
-
InsertManyOperation,
|
|
56
|
-
InsertManyResult
|
|
68
|
+
InsertOneResult
|
|
57
69
|
} from './operations/insert';
|
|
58
|
-
import {
|
|
59
|
-
UpdateOneOperation,
|
|
60
|
-
UpdateManyOperation,
|
|
61
|
-
UpdateOptions,
|
|
62
|
-
UpdateResult,
|
|
63
|
-
ReplaceOneOperation,
|
|
64
|
-
ReplaceOptions
|
|
65
|
-
} from './operations/update';
|
|
66
|
-
import {
|
|
67
|
-
DeleteOneOperation,
|
|
68
|
-
DeleteManyOperation,
|
|
69
|
-
DeleteOptions,
|
|
70
|
-
DeleteResult
|
|
71
|
-
} from './operations/delete';
|
|
72
70
|
import { IsCappedOperation } from './operations/is_capped';
|
|
73
71
|
import {
|
|
74
|
-
MapReduceOperation,
|
|
75
72
|
MapFunction,
|
|
76
|
-
|
|
77
|
-
MapReduceOptions
|
|
73
|
+
MapReduceOperation,
|
|
74
|
+
MapReduceOptions,
|
|
75
|
+
ReduceFunction
|
|
78
76
|
} from './operations/map_reduce';
|
|
77
|
+
import type { Hint, OperationOptions } from './operations/operation';
|
|
79
78
|
import { OptionsOperation } from './operations/options_operation';
|
|
80
79
|
import { RenameOperation, RenameOptions } from './operations/rename';
|
|
81
80
|
import { CollStats, CollStatsOperation, CollStatsOptions } from './operations/stats';
|
|
82
|
-
import {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
import
|
|
91
|
-
import
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
81
|
+
import {
|
|
82
|
+
ReplaceOneOperation,
|
|
83
|
+
ReplaceOptions,
|
|
84
|
+
UpdateManyOperation,
|
|
85
|
+
UpdateOneOperation,
|
|
86
|
+
UpdateOptions,
|
|
87
|
+
UpdateResult
|
|
88
|
+
} from './operations/update';
|
|
89
|
+
import { ReadConcern, ReadConcernLike } from './read_concern';
|
|
90
|
+
import { ReadPreference, ReadPreferenceLike } from './read_preference';
|
|
91
|
+
import {
|
|
92
|
+
Callback,
|
|
93
|
+
checkCollectionName,
|
|
94
|
+
DEFAULT_PK_FACTORY,
|
|
95
|
+
emitWarningOnce,
|
|
96
|
+
getTopology,
|
|
97
|
+
MongoDBNamespace,
|
|
98
|
+
normalizeHintField,
|
|
99
|
+
resolveOptions
|
|
100
|
+
} from './utils';
|
|
101
|
+
import { WriteConcern, WriteConcernOptions } from './write_concern';
|
|
99
102
|
|
|
100
103
|
/** @public */
|
|
101
104
|
export interface ModifyResult<TSchema = Document> {
|
|
@@ -109,6 +112,9 @@ export interface CollectionOptions
|
|
|
109
112
|
extends BSONSerializeOptions,
|
|
110
113
|
WriteConcernOptions,
|
|
111
114
|
LoggerOptions {
|
|
115
|
+
/**
|
|
116
|
+
* @deprecated Use readPreference instead
|
|
117
|
+
*/
|
|
112
118
|
slaveOk?: boolean;
|
|
113
119
|
/** Specify a read concern for the collection. (only MongoDB 3.2 or higher supported) */
|
|
114
120
|
readConcern?: ReadConcernLike;
|
|
@@ -124,7 +130,6 @@ export interface CollectionPrivate {
|
|
|
124
130
|
namespace: MongoDBNamespace;
|
|
125
131
|
readPreference?: ReadPreference;
|
|
126
132
|
bsonOptions: BSONSerializeOptions;
|
|
127
|
-
slaveOk?: boolean;
|
|
128
133
|
collectionHint?: Hint;
|
|
129
134
|
readConcern?: ReadConcern;
|
|
130
135
|
writeConcern?: WriteConcern;
|
|
@@ -178,8 +183,7 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
178
183
|
readPreference: ReadPreference.fromOptions(options),
|
|
179
184
|
bsonOptions: resolveBSONOptions(options, db),
|
|
180
185
|
readConcern: ReadConcern.fromOptions(options),
|
|
181
|
-
writeConcern: WriteConcern.fromOptions(options)
|
|
182
|
-
slaveOk: options == null || options.slaveOk == null ? db.slaveOk : options.slaveOk
|
|
186
|
+
writeConcern: WriteConcern.fromOptions(options)
|
|
183
187
|
};
|
|
184
188
|
}
|
|
185
189
|
|
|
@@ -261,16 +265,22 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
261
265
|
* @param options - Optional settings for the command
|
|
262
266
|
* @param callback - An optional callback, a Promise will be returned if none is provided
|
|
263
267
|
*/
|
|
264
|
-
insertOne(doc:
|
|
265
|
-
insertOne(
|
|
266
|
-
|
|
268
|
+
insertOne(doc: OptionalUnlessRequiredId<TSchema>): Promise<InsertOneResult<TSchema>>;
|
|
269
|
+
insertOne(
|
|
270
|
+
doc: OptionalUnlessRequiredId<TSchema>,
|
|
271
|
+
callback: Callback<InsertOneResult<TSchema>>
|
|
272
|
+
): void;
|
|
267
273
|
insertOne(
|
|
268
|
-
doc:
|
|
274
|
+
doc: OptionalUnlessRequiredId<TSchema>,
|
|
275
|
+
options: InsertOneOptions
|
|
276
|
+
): Promise<InsertOneResult<TSchema>>;
|
|
277
|
+
insertOne(
|
|
278
|
+
doc: OptionalUnlessRequiredId<TSchema>,
|
|
269
279
|
options: InsertOneOptions,
|
|
270
280
|
callback: Callback<InsertOneResult<TSchema>>
|
|
271
281
|
): void;
|
|
272
282
|
insertOne(
|
|
273
|
-
doc:
|
|
283
|
+
doc: OptionalUnlessRequiredId<TSchema>,
|
|
274
284
|
options?: InsertOneOptions | Callback<InsertOneResult<TSchema>>,
|
|
275
285
|
callback?: Callback<InsertOneResult<TSchema>>
|
|
276
286
|
): Promise<InsertOneResult<TSchema>> | void {
|
|
@@ -305,19 +315,22 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
305
315
|
* @param options - Optional settings for the command
|
|
306
316
|
* @param callback - An optional callback, a Promise will be returned if none is provided
|
|
307
317
|
*/
|
|
308
|
-
insertMany(docs:
|
|
309
|
-
insertMany(
|
|
318
|
+
insertMany(docs: OptionalUnlessRequiredId<TSchema>[]): Promise<InsertManyResult<TSchema>>;
|
|
319
|
+
insertMany(
|
|
320
|
+
docs: OptionalUnlessRequiredId<TSchema>[],
|
|
321
|
+
callback: Callback<InsertManyResult<TSchema>>
|
|
322
|
+
): void;
|
|
310
323
|
insertMany(
|
|
311
|
-
docs:
|
|
324
|
+
docs: OptionalUnlessRequiredId<TSchema>[],
|
|
312
325
|
options: BulkWriteOptions
|
|
313
326
|
): Promise<InsertManyResult<TSchema>>;
|
|
314
327
|
insertMany(
|
|
315
|
-
docs:
|
|
328
|
+
docs: OptionalUnlessRequiredId<TSchema>[],
|
|
316
329
|
options: BulkWriteOptions,
|
|
317
330
|
callback: Callback<InsertManyResult<TSchema>>
|
|
318
331
|
): void;
|
|
319
332
|
insertMany(
|
|
320
|
-
docs:
|
|
333
|
+
docs: OptionalUnlessRequiredId<TSchema>[],
|
|
321
334
|
options?: BulkWriteOptions | Callback<InsertManyResult<TSchema>>,
|
|
322
335
|
callback?: Callback<InsertManyResult<TSchema>>
|
|
323
336
|
): Promise<InsertManyResult<TSchema>> | void {
|
|
@@ -459,26 +472,29 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
459
472
|
* @param options - Optional settings for the command
|
|
460
473
|
* @param callback - An optional callback, a Promise will be returned if none is provided
|
|
461
474
|
*/
|
|
462
|
-
replaceOne(filter: Filter<TSchema>, replacement: TSchema): Promise<UpdateResult | Document>;
|
|
463
475
|
replaceOne(
|
|
464
476
|
filter: Filter<TSchema>,
|
|
465
|
-
replacement: TSchema
|
|
477
|
+
replacement: WithoutId<TSchema>
|
|
478
|
+
): Promise<UpdateResult | Document>;
|
|
479
|
+
replaceOne(
|
|
480
|
+
filter: Filter<TSchema>,
|
|
481
|
+
replacement: WithoutId<TSchema>,
|
|
466
482
|
callback: Callback<UpdateResult | Document>
|
|
467
483
|
): void;
|
|
468
484
|
replaceOne(
|
|
469
485
|
filter: Filter<TSchema>,
|
|
470
|
-
replacement: TSchema
|
|
486
|
+
replacement: WithoutId<TSchema>,
|
|
471
487
|
options: ReplaceOptions
|
|
472
488
|
): Promise<UpdateResult | Document>;
|
|
473
489
|
replaceOne(
|
|
474
490
|
filter: Filter<TSchema>,
|
|
475
|
-
replacement: TSchema
|
|
491
|
+
replacement: WithoutId<TSchema>,
|
|
476
492
|
options: ReplaceOptions,
|
|
477
493
|
callback: Callback<UpdateResult | Document>
|
|
478
494
|
): void;
|
|
479
495
|
replaceOne(
|
|
480
496
|
filter: Filter<TSchema>,
|
|
481
|
-
replacement: TSchema
|
|
497
|
+
replacement: WithoutId<TSchema>,
|
|
482
498
|
options?: ReplaceOptions | Callback<UpdateResult | Document>,
|
|
483
499
|
callback?: Callback<UpdateResult | Document>
|
|
484
500
|
): Promise<UpdateResult | Document> | void {
|
|
@@ -676,12 +692,16 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
676
692
|
* @param options - Optional settings for the command
|
|
677
693
|
* @param callback - An optional callback, a Promise will be returned if none is provided
|
|
678
694
|
*/
|
|
679
|
-
findOne(): Promise<TSchema | null>;
|
|
680
|
-
findOne(callback: Callback<TSchema | null>): void;
|
|
681
|
-
findOne(filter: Filter<TSchema>): Promise<TSchema | null>;
|
|
682
|
-
findOne(filter: Filter<TSchema>, callback: Callback<TSchema | null>): void;
|
|
683
|
-
findOne(filter: Filter<TSchema>, options: FindOptions): Promise<TSchema | null>;
|
|
684
|
-
findOne(
|
|
695
|
+
findOne(): Promise<WithId<TSchema> | null>;
|
|
696
|
+
findOne(callback: Callback<WithId<TSchema> | null>): void;
|
|
697
|
+
findOne(filter: Filter<TSchema>): Promise<WithId<TSchema> | null>;
|
|
698
|
+
findOne(filter: Filter<TSchema>, callback: Callback<WithId<TSchema> | null>): void;
|
|
699
|
+
findOne(filter: Filter<TSchema>, options: FindOptions): Promise<WithId<TSchema> | null>;
|
|
700
|
+
findOne(
|
|
701
|
+
filter: Filter<TSchema>,
|
|
702
|
+
options: FindOptions,
|
|
703
|
+
callback: Callback<WithId<TSchema> | null>
|
|
704
|
+
): void;
|
|
685
705
|
|
|
686
706
|
// allow an override of the schema.
|
|
687
707
|
findOne<T = TSchema>(): Promise<T | null>;
|
|
@@ -695,10 +715,10 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
695
715
|
): void;
|
|
696
716
|
|
|
697
717
|
findOne(
|
|
698
|
-
filter?: Filter<TSchema> | Callback<TSchema | null>,
|
|
699
|
-
options?: FindOptions | Callback<TSchema | null>,
|
|
700
|
-
callback?: Callback<TSchema | null>
|
|
701
|
-
): Promise<TSchema | null> | void {
|
|
718
|
+
filter?: Filter<TSchema> | Callback<WithId<TSchema> | null>,
|
|
719
|
+
options?: FindOptions | Callback<WithId<TSchema> | null>,
|
|
720
|
+
callback?: Callback<WithId<TSchema> | null>
|
|
721
|
+
): Promise<WithId<TSchema> | null> | void {
|
|
702
722
|
if (callback != null && typeof callback !== 'function') {
|
|
703
723
|
throw new MongoInvalidArgumentError(
|
|
704
724
|
'Third parameter to `findOne()` must be a callback or undefined'
|
|
@@ -706,7 +726,7 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
706
726
|
}
|
|
707
727
|
|
|
708
728
|
if (typeof filter === 'function') {
|
|
709
|
-
callback = filter as Callback<TSchema | null>;
|
|
729
|
+
callback = filter as Callback<WithId<TSchema> | null>;
|
|
710
730
|
filter = {};
|
|
711
731
|
options = {};
|
|
712
732
|
}
|
|
@@ -725,10 +745,10 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
725
745
|
*
|
|
726
746
|
* @param filter - The filter predicate. If unspecified, then all documents in the collection will match the predicate
|
|
727
747
|
*/
|
|
728
|
-
find(): FindCursor<TSchema
|
|
729
|
-
find(filter: Filter<TSchema>, options?: FindOptions): FindCursor<TSchema
|
|
748
|
+
find(): FindCursor<WithId<TSchema>>;
|
|
749
|
+
find(filter: Filter<TSchema>, options?: FindOptions): FindCursor<WithId<TSchema>>;
|
|
730
750
|
find<T>(filter: Filter<TSchema>, options?: FindOptions): FindCursor<T>;
|
|
731
|
-
find(filter?: Filter<TSchema>, options?: FindOptions): FindCursor<TSchema
|
|
751
|
+
find(filter?: Filter<TSchema>, options?: FindOptions): FindCursor<WithId<TSchema>> {
|
|
732
752
|
if (arguments.length > 2) {
|
|
733
753
|
throw new MongoInvalidArgumentError(
|
|
734
754
|
'Method "collection.find()" accepts at most two arguments'
|
|
@@ -738,7 +758,7 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
738
758
|
throw new MongoInvalidArgumentError('Argument "options" must not be function');
|
|
739
759
|
}
|
|
740
760
|
|
|
741
|
-
return new FindCursor<TSchema
|
|
761
|
+
return new FindCursor<WithId<TSchema>>(
|
|
742
762
|
getTopology(this),
|
|
743
763
|
this.s.namespace,
|
|
744
764
|
filter,
|
|
@@ -1275,26 +1295,29 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
1275
1295
|
* @param options - Optional settings for the command
|
|
1276
1296
|
* @param callback - An optional callback, a Promise will be returned if none is provided
|
|
1277
1297
|
*/
|
|
1278
|
-
findOneAndReplace(filter: Filter<TSchema>, replacement: Document): Promise<ModifyResult<TSchema>>;
|
|
1279
1298
|
findOneAndReplace(
|
|
1280
1299
|
filter: Filter<TSchema>,
|
|
1281
|
-
replacement:
|
|
1300
|
+
replacement: WithoutId<TSchema>
|
|
1301
|
+
): Promise<ModifyResult<TSchema>>;
|
|
1302
|
+
findOneAndReplace(
|
|
1303
|
+
filter: Filter<TSchema>,
|
|
1304
|
+
replacement: WithoutId<TSchema>,
|
|
1282
1305
|
callback: Callback<ModifyResult<TSchema>>
|
|
1283
1306
|
): void;
|
|
1284
1307
|
findOneAndReplace(
|
|
1285
1308
|
filter: Filter<TSchema>,
|
|
1286
|
-
replacement:
|
|
1309
|
+
replacement: WithoutId<TSchema>,
|
|
1287
1310
|
options: FindOneAndReplaceOptions
|
|
1288
1311
|
): Promise<ModifyResult<TSchema>>;
|
|
1289
1312
|
findOneAndReplace(
|
|
1290
1313
|
filter: Filter<TSchema>,
|
|
1291
|
-
replacement:
|
|
1314
|
+
replacement: WithoutId<TSchema>,
|
|
1292
1315
|
options: FindOneAndReplaceOptions,
|
|
1293
1316
|
callback: Callback<ModifyResult<TSchema>>
|
|
1294
1317
|
): void;
|
|
1295
1318
|
findOneAndReplace(
|
|
1296
1319
|
filter: Filter<TSchema>,
|
|
1297
|
-
replacement:
|
|
1320
|
+
replacement: WithoutId<TSchema>,
|
|
1298
1321
|
options?: FindOneAndReplaceOptions | Callback<ModifyResult<TSchema>>,
|
|
1299
1322
|
callback?: Callback<ModifyResult<TSchema>>
|
|
1300
1323
|
): Promise<ModifyResult<TSchema>> | void {
|
|
@@ -1415,6 +1438,7 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
1415
1438
|
/**
|
|
1416
1439
|
* Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
|
|
1417
1440
|
*
|
|
1441
|
+
* @deprecated collection.mapReduce is deprecated. Use the aggregation pipeline instead. Visit https://docs.mongodb.com/manual/reference/map-reduce-to-aggregation-pipeline for more information on how to translate map-reduce operations to the aggregation pipeline.
|
|
1418
1442
|
* @param map - The mapping function.
|
|
1419
1443
|
* @param reduce - The reduce function.
|
|
1420
1444
|
* @param options - Optional settings for the command
|
|
@@ -1446,6 +1470,9 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
1446
1470
|
options?: MapReduceOptions<TKey, TValue> | Callback<Document | Document[]>,
|
|
1447
1471
|
callback?: Callback<Document | Document[]>
|
|
1448
1472
|
): Promise<Document | Document[]> | void {
|
|
1473
|
+
emitWarningOnce(
|
|
1474
|
+
'collection.mapReduce is deprecated. Use the aggregation pipeline instead. Visit https://docs.mongodb.com/manual/reference/map-reduce-to-aggregation-pipeline for more information on how to translate map-reduce operations to the aggregation pipeline.'
|
|
1475
|
+
);
|
|
1449
1476
|
if ('function' === typeof options) (callback = options), (options = {});
|
|
1450
1477
|
// Out must always be defined (make sure we don't break weirdly on pre 1.8+ servers)
|
|
1451
1478
|
// TODO NODE-3339: Figure out if this is still necessary given we no longer officially support pre-1.8
|
|
@@ -1509,7 +1536,7 @@ export class Collection<TSchema extends Document = Document> {
|
|
|
1509
1536
|
* @param callback - An optional callback, a Promise will be returned if none is provided
|
|
1510
1537
|
*/
|
|
1511
1538
|
insert(
|
|
1512
|
-
docs:
|
|
1539
|
+
docs: OptionalUnlessRequiredId<TSchema>[],
|
|
1513
1540
|
options: BulkWriteOptions,
|
|
1514
1541
|
callback: Callback<InsertManyResult<TSchema>>
|
|
1515
1542
|
): Promise<InsertManyResult<TSchema>> | void {
|