diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts
index 19f9b509c4..2547fbee28 100644
--- a/types/mongodb/index.d.ts
+++ b/types/mongodb/index.d.ts
@@ -24,14 +24,14 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
-// Documentation: http://mongodb.github.io/node-mongodb-native/3.1/api/
+// Documentation: https://mongodb.github.io/node-mongodb-native/3.1/api/
///
-///
import { ObjectID, Timestamp } from 'bson';
import { EventEmitter } from 'events';
import { Readable, Writable } from "stream";
+import { checkServerIdentity } from "tls";
export function connect(uri: string, options?: MongoClientOptions): Promise;
export function connect(uri: string, callback: MongoCallback): void;
@@ -54,7 +54,7 @@ export class MongoClient extends EventEmitter {
close(force?: boolean): Promise;
close(force: boolean, callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#db */
- db(dbName?: string, options?: MongoClientCommonOption): Db
+ db(dbName?: string, options?: MongoClientCommonOption): Db;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#isConnected */
isConnected(options?: MongoClientCommonOption): boolean;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#logout */
@@ -64,7 +64,7 @@ export class MongoClient extends EventEmitter {
/** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#startSession */
startSession(options?: SessionOptions): ClientSession;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#watch */
- watch(pipeline?: Object[], options?: ChangeStreamOptions & { startAtClusterTime?: Timestamp, session?: ClientSession }): ChangeStream;
+ watch(pipeline?: object[], options?: ChangeStreamOptions & { startAtClusterTime?: Timestamp, session?: ClientSession }): ChangeStream;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#withSession */
withSession(operation: (session: ClientSession) => Promise): Promise;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#withSession */
@@ -208,7 +208,7 @@ export interface MongoCallback {
/** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoError.html */
export class MongoError extends Error {
constructor(message: string);
- static create(options: Object): MongoError;
+ static create(options: object): MongoError;
code?: number;
/**
* While not documented, the 'errmsg' prop is AFAIK the only way to find out
@@ -249,13 +249,13 @@ export interface MongoClientOptions extends
/**
* Custom logger object
*/
- logger?: Object | log;
+ logger?: object | log;
/**
* Validate MongoClient passed in options for correctness.
* Default: false
*/
- validateOptions?: Object;
+ validateOptions?: object;
/**
* The name of the application that created this MongoClient instance.
@@ -315,7 +315,7 @@ export interface SSLOptions {
/**
* Default: true; Server identity checking during SSL
*/
- checkServerIdentity?: boolean | Function;
+ checkServerIdentity?: boolean | typeof checkServerIdentity;
/**
* Array of valid certificates either as Buffers or Strings
*/
@@ -359,7 +359,7 @@ export interface HighAvailabilityOptions {
// See http://mongodb.github.io/node-mongodb-native/3.1/api/ReadPreference.html
export class ReadPreference {
- constructor(mode: string, tags: Object);
+ constructor(mode: string, tags: object);
mode: string;
tags: any;
options: {
@@ -418,15 +418,15 @@ export interface DbCreateOptions extends CommonOptions {
/**
* Default: true; Promotes BSON values to native types where possible, set to false to only receive wrapper types.
*/
- promoteValues?: Object;
+ promoteValues?: boolean;
/**
* Custom primary key factory to generate _id values (see Custom primary keys).
*/
- pkFactory?: Object;
+ pkFactory?: object;
/**
* ES6 compatible promise constructor
*/
- promiseLibrary?: Object;
+ promiseLibrary?: object;
/**
* https://docs.mongodb.com/manual/reference/read-concern/#read-concern
**/
@@ -562,17 +562,17 @@ export class Db extends EventEmitter {
collections(): Promise[]>;
collections(callback: MongoCallback[]>): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#command */
- command(command: Object, callback: MongoCallback): void;
- command(command: Object, options?: { readPreference: ReadPreference | string }): Promise;
- command(command: Object, options: { readPreference: ReadPreference | string }, callback: MongoCallback): void;
+ command(command: object, callback: MongoCallback): void;
+ command(command: object, options?: { readPreference: ReadPreference | string, session?: ClientSession }): Promise;
+ command(command: object, options: { readPreference: ReadPreference | string, session?: ClientSession }, callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#createCollection */
createCollection(name: string, callback: MongoCallback>): void;
createCollection(name: string, options?: CollectionCreateOptions): Promise>;
createCollection(name: string, options: CollectionCreateOptions, callback: MongoCallback>): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#createIndex */
- createIndex(name: string, fieldOrSpec: string | Object, callback: MongoCallback): void;
- createIndex(name: string, fieldOrSpec: string | Object, options?: IndexOptions): Promise;
- createIndex(name: string, fieldOrSpec: string | Object, options: IndexOptions, callback: MongoCallback): void;
+ createIndex(name: string, fieldOrSpec: string | object, callback: MongoCallback): void;
+ createIndex(name: string, fieldOrSpec: string | object, options?: IndexOptions): Promise;
+ createIndex(name: string, fieldOrSpec: string | object, options: IndexOptions, callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#dropCollection */
dropCollection(name: string): Promise;
dropCollection(name: string, callback: MongoCallback): void;
@@ -580,15 +580,15 @@ export class Db extends EventEmitter {
dropDatabase(): Promise;
dropDatabase(callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#executeDbAdminCommand */
- executeDbAdminCommand(command: Object, callback: MongoCallback): void;
- executeDbAdminCommand(command: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise;
- executeDbAdminCommand(command: Object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void;
+ executeDbAdminCommand(command: object, callback: MongoCallback): void;
+ executeDbAdminCommand(command: object, options?: { readPreference?: ReadPreference | string, session?: ClientSession }): Promise;
+ executeDbAdminCommand(command: object, options: { readPreference?: ReadPreference | string, session?: ClientSession }, callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#indexInformation */
indexInformation(name: string, callback: MongoCallback): void;
indexInformation(name: string, options?: { full?: boolean, readPreference?: ReadPreference | string }): Promise;
indexInformation(name: string, options: { full?: boolean, readPreference?: ReadPreference | string }, callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#listCollections */
- listCollections(filter?: Object, options?: { nameOnly?: boolean, batchSize?: number, readPreference?: ReadPreference | string, session?: ClientSession }): CommandCursor;
+ listCollections(filter?: object, options?: { nameOnly?: boolean, batchSize?: number, readPreference?: ReadPreference | string, session?: ClientSession }): CommandCursor;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#profilingInfo */
/** @deprecated Query the system.profile collection directly. */
profilingInfo(callback: MongoCallback): void;
@@ -655,14 +655,14 @@ export class Mongos extends EventEmitter {
* @see http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#addUser
*/
export interface DbAddUserOptions extends CommonOptions {
- customData?: Object;
- roles?: Object[];
+ customData?: object;
+ roles?: object[];
}
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#createCollection */
export interface CollectionCreateOptions extends CommonOptions {
raw?: boolean;
- pkFactory?: Object;
+ pkFactory?: object;
readPreference?: ReadPreference | string;
serializeFunctions?: boolean;
strict?: boolean;
@@ -684,7 +684,7 @@ export interface CollectionCreateOptions extends CommonOptions {
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#collection */
export interface DbCollectionOptions extends CommonOptions {
raw?: boolean;
- pkFactory?: Object;
+ pkFactory?: object;
readPreference?: ReadPreference | string;
serializeFunctions?: boolean;
strict?: boolean;
@@ -750,9 +750,9 @@ export interface Admin {
buildInfo(): Promise;
buildInfo(callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Admin.html#command */
- command(command: Object, callback: MongoCallback): void;
- command(command: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise;
- command(command: Object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void;
+ command(command: object, callback: MongoCallback): void;
+ command(command: object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise;
+ command(command: object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Admin.html#listDatabases */
listDatabases(): Promise;
listDatabases(callback: MongoCallback): void;
@@ -774,15 +774,15 @@ export interface Admin {
serverStatus(callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Admin.html#validateCollection */
validateCollection(collectionNme: string, callback: MongoCallback): void;
- validateCollection(collectionNme: string, options?: Object): Promise;
- validateCollection(collectionNme: string, options: Object, callback: MongoCallback): void;
+ validateCollection(collectionNme: string, options?: object): Promise;
+ validateCollection(collectionNme: string, options: object, callback: MongoCallback): void;
}
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Admin.html#addUser */
export interface AddUserOptions extends CommonOptions {
fsync: boolean;
- customData?: Object;
- roles?: Object[]
+ customData?: object;
+ roles?: object[]
}
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Admin.html#removeUser */
@@ -814,12 +814,12 @@ export interface Collection {
hint: any;
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#aggregate */
aggregate(callback: MongoCallback>): AggregationCursor;
- aggregate(pipeline: Object[], callback: MongoCallback>): AggregationCursor;
- aggregate(pipeline?: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback>): AggregationCursor;
+ aggregate(pipeline: object[], callback: MongoCallback>): AggregationCursor;
+ aggregate(pipeline?: object[], options?: CollectionAggregationOptions, callback?: MongoCallback>): AggregationCursor;
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#bulkWrite */
- bulkWrite(operations: Object[], callback: MongoCallback): void;
- bulkWrite(operations: Object[], options?: CollectionBulkWriteOptions): Promise;
- bulkWrite(operations: Object[], options: CollectionBulkWriteOptions, callback: MongoCallback): void;
+ bulkWrite(operations: object[], callback: MongoCallback): void;
+ bulkWrite(operations: object[], options?: CollectionBulkWriteOptions): Promise;
+ bulkWrite(operations: object[], options: CollectionBulkWriteOptions, callback: MongoCallback): void;
/**
* http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#count
* @deprecated Use countDocuments or estimatedDocumentCount
@@ -880,12 +880,12 @@ export interface Collection {
findOne(filter: FilterQuery, options: FindOneOptions, callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#findOneAndDelete */
findOneAndDelete(filter: FilterQuery, callback: MongoCallback>): void;
- findOneAndDelete(filter: FilterQuery, options?: { projection?: Object, sort?: Object, maxTimeMS?: number, session?: ClientSession }): Promise>;
- findOneAndDelete(filter: FilterQuery, options: { projection?: Object, sort?: Object, maxTimeMS?: number, session?: ClientSession }, callback: MongoCallback>): void;
+ findOneAndDelete(filter: FilterQuery, options?: { projection?: object, sort?: object, maxTimeMS?: number, session?: ClientSession }): Promise>;
+ findOneAndDelete(filter: FilterQuery, options: { projection?: object, sort?: object, maxTimeMS?: number, session?: ClientSession }, callback: MongoCallback>): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#findOneAndReplace */
- findOneAndReplace(filter: FilterQuery, replacement: Object, callback: MongoCallback>): void;
- findOneAndReplace(filter: FilterQuery, replacement: Object, options?: FindOneAndReplaceOption): Promise>;
- findOneAndReplace(filter: FilterQuery, replacement: Object, options: FindOneAndReplaceOption, callback: MongoCallback>): void;
+ findOneAndReplace(filter: FilterQuery, replacement: object, callback: MongoCallback>): void;
+ findOneAndReplace(filter: FilterQuery, replacement: object, options?: FindOneAndReplaceOption): Promise>;
+ findOneAndReplace(filter: FilterQuery, replacement: object, options: FindOneAndReplaceOption, callback: MongoCallback>): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#findOneAndUpdate */
findOneAndUpdate(filter: FilterQuery, update: UpdateQuery | TSchema, callback: MongoCallback>): void;
findOneAndUpdate(filter: FilterQuery, update: UpdateQuery | TSchema, options?: FindOneAndUpdateOption): Promise>;
@@ -894,14 +894,13 @@ export interface Collection {
geoHaystackSearch(x: number, y: number, callback: MongoCallback): void;
geoHaystackSearch(x: number, y: number, options?: GeoHaystackSearchOptions): Promise;
geoHaystackSearch(x: number, y: number, options: GeoHaystackSearchOptions, callback: MongoCallback): void;
- /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#geoNear */
- geoNear(x: number, y: number, callback: MongoCallback): void;
- geoNear(x: number, y: number, options?: GeoNearOptions): Promise;
- geoNear(x: number, y: number, options: GeoNearOptions, callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#group */
- group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, callback: MongoCallback): void;
- group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options?: { readPreference?: ReadPreference | string }): Promise;
- group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options: { readPreference?: ReadPreference | string }, callback: MongoCallback): void;
+ /** @deprecated MongoDB 3.6 or higher no longer supports the group command. We recommend rewriting using the aggregation framework. */
+ group(keys: object | Array | Function | Code, condition: object, initial: object, reduce: Function | Code, finalize: Function | Code, command: boolean, callback: MongoCallback): void;
+ /** @deprecated MongoDB 3.6 or higher no longer supports the group command. We recommend rewriting using the aggregation framework. */
+ group(keys: object | Array | Function | Code, condition: object, initial: object, reduce: Function | Code, finalize: Function | Code, command: boolean, options?: { readPreference?: ReadPreference | string, session?: ClientSession }): Promise;
+ /** @deprecated MongoDB 3.6 or higher no longer supports the group command. We recommend rewriting using the aggregation framework. */
+ group(keys: object | Array | Function | Code, condition: object, initial: object, reduce: Function | Code, finalize: Function | Code, command: boolean, options: { readPreference?: ReadPreference | string, session?: ClientSession }, callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#indexes */
indexes(options?: { session: ClientSession }): Promise;
indexes(callback: MongoCallback): void;
@@ -940,9 +939,9 @@ export interface Collection {
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#listIndexes */
listIndexes(options?: { batchSize?: number, readPreference?: ReadPreference | string, session?: ClientSession }): CommandCursor;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#mapReduce */
- mapReduce(map: Function | string, reduce: Function | string, callback: MongoCallback): void;
- mapReduce(map: Function | string, reduce: Function | string, options?: MapReduceOptions): Promise;
- mapReduce(map: Function | string, reduce: Function | string, options: MapReduceOptions, callback: MongoCallback): void;
+ mapReduce(map: CollectionMapFunction | string, reduce: CollectionReduceFunction | string, callback: MongoCallback): void;
+ mapReduce(map: CollectionMapFunction | string, reduce: CollectionReduceFunction | string, options?: MapReduceOptions): Promise;
+ mapReduce(map: CollectionMapFunction | string, reduce: CollectionReduceFunction | string, options: MapReduceOptions, callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#options */
options(options?: { session: ClientSession }): Promise;
options(callback: MongoCallback): void;
@@ -957,11 +956,11 @@ export interface Collection {
reIndex(options: { session: ClientSession }, callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#remove */
/** @deprecated Use use deleteOne, deleteMany or bulkWrite */
- remove(selector: Object, callback: MongoCallback): void;
+ remove(selector: object, callback: MongoCallback): void;
/** @deprecated Use use deleteOne, deleteMany or bulkWrite */
- remove(selector: Object, options?: CommonOptions & { single?: boolean }): Promise;
+ remove(selector: object, options?: CommonOptions & { single?: boolean }): Promise;
/** @deprecated Use use deleteOne, deleteMany or bulkWrite */
- remove(selector: Object, options?: CommonOptions & { single?: boolean }, callback?: MongoCallback): void;
+ remove(selector: object, options?: CommonOptions & { single?: boolean }, callback?: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#rename */
rename(newName: string, callback: MongoCallback>): void;
rename(newName: string, options?: { dropTarget?: boolean, session?: ClientSession }): Promise>;
@@ -997,7 +996,7 @@ export interface Collection {
updateOne(filter: FilterQuery, update: UpdateQuery | TSchema, options?: UpdateOneOptions): Promise;
updateOne(filter: FilterQuery, update: UpdateQuery | TSchema, options: UpdateOneOptions, callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#watch */
- watch(pipeline?: Object[], options?: ChangeStreamOptions & { startAtClusterTime?: Timestamp, session?: ClientSession }): ChangeStream;
+ watch(pipeline?: object[], options?: ChangeStreamOptions & { startAtClusterTime?: Timestamp, session?: ClientSession }): ChangeStream;
}
export type Condition = {
@@ -1023,17 +1022,17 @@ export type Condition = {
$caseSensitive?: boolean;
$diacraticSensitive?: boolean;
};
- $where?: Object;
- $geoIntersects?: Object;
- $geoWithin?: Object;
- $near?: Object;
- $nearSphere?: Object;
- $elemMatch?: Object;
+ $where?: object;
+ $geoIntersects?: object;
+ $geoWithin?: object;
+ $near?: object;
+ $nearSphere?: object;
+ $elemMatch?: object;
$size?: number;
- $bitsAllClear?: Object;
- $bitsAllSet?: Object;
- $bitsAnyClear?: Object;
- $bitsAnySet?: Object;
+ $bitsAllClear?: object;
+ $bitsAllSet?: object;
+ $bitsAnyClear?: object;
+ $bitsAnySet?: object;
[key: string]: any;
};
@@ -1403,8 +1402,8 @@ export interface FindAndModifyWriteOpResultObject {
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#findOneAndReplace */
export interface FindOneAndReplaceOption extends CommonOptions {
- projection?: Object;
- sort?: Object;
+ projection?: object;
+ sort?: object;
maxTimeMS?: number;
upsert?: boolean;
returnOriginal?: boolean;
@@ -1412,34 +1411,21 @@ export interface FindOneAndReplaceOption extends CommonOptions {
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#findOneAndUpdate */
export interface FindOneAndUpdateOption extends FindOneAndReplaceOption {
- arrayFilters?: Object[];
+ arrayFilters?: object[];
}
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#geoHaystackSearch */
export interface GeoHaystackSearchOptions {
readPreference?: ReadPreference | string;
maxDistance?: number;
- search?: Object;
+ search?: object;
limit?: number;
session?: ClientSession;
}
-/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#geoNear */
-export interface GeoNearOptions {
- readPreference?: ReadPreference | string;
- num?: number;
- minDistance?: number;
- maxDistance?: number;
- distanceMultiplier?: number;
- query?: Object;
- spherical?: boolean;
- uniqueDocs?: boolean;
- includeLocs?: boolean;
-}
-
/** http://mongodb.github.io/node-mongodb-native/3.1/api/Code.html */
export class Code {
- constructor(code: string | Function, scope?: Object)
+ constructor(code: string | Function, scope?: object)
code: string | Function;
scope: any;
}
@@ -1452,9 +1438,9 @@ export interface OrderedBulkOperation {
execute(options?: FSyncOptions): Promise;
execute(options: FSyncOptions, callback: MongoCallback): void;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/OrderedBulkOperation.html#find */
- find(selector: Object): FindOperatorsOrdered;
+ find(selector: object): FindOperatorsOrdered;
/** http://mongodb.github.io/node-mongodb-native/3.1/api/OrderedBulkOperation.html#insert */
- insert(doc: Object): OrderedBulkOperation;
+ insert(doc: object): OrderedBulkOperation;
}
/** http://mongodb.github.io/node-mongodb-native/3.1/api/BulkWriteResult.html */
@@ -1466,15 +1452,15 @@ export interface BulkWriteResult {
nModified: number;
nRemoved: number;
- getInsertedIds(): Array