From f80a0dc0d99660ee400e588ff35fda2aeb57f0ae Mon Sep 17 00:00:00 2001 From: Anatoly Demidovich Date: Thu, 17 Aug 2017 09:35:06 +0300 Subject: [PATCH] Add connect() and ObjectId --- types/mongodb/index.d.ts | 2494 +++++++++++++++++++------------------- 1 file changed, 1251 insertions(+), 1243 deletions(-) diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index 0105c6104d..07b501f062 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -15,1257 +15,1265 @@ import { ObjectID } from 'bson'; import { EventEmitter } from 'events'; import { Readable, Writable } from "stream"; -export { Binary, Double, Long, Decimal128, MaxKey, MinKey, ObjectID, Timestamp } from 'bson'; - -// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/MongoClient.html -export class MongoClient { - constructor(); - - static connect(uri: string, callback: MongoCallback): void; - static connect(uri: string, options?: MongoClientOptions): Promise; - static connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; - - connect(uri: string, callback: MongoCallback): void; - connect(uri: string, options?: MongoClientOptions): Promise; - connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; -} - -export interface MongoCallback { - (error: MongoError, result: T): void; -} - -// http://mongodb.github.io/node-mongodb-native/2.1/api/MongoError.html -export class MongoError extends Error { - constructor(message: string); - static create(options: Object): MongoError; - code?: number; -} - -// http://mongodb.github.io/node-mongodb-native/2.2/api/MongoClient.html#.connect -export interface MongoClientOptions extends - DbCreateOptions, - ServerOptions, - MongosOptions, - ReplSetOptions, - SocketOptions, - SSLOptions, - HighAvailabilityOptions { - // The logging level (error/warn/info/debug) - loggerLevel?: string; - // Custom logger object - logger?: Object; - // Default: false; - validateOptions?: Object; -} - -export interface SSLOptions { - // Default:5; Number of connections for each server instance - poolSize?: number; - // Use ssl connection (needs to have a mongod server with ssl support) - ssl?: boolean; - // Default: true; Validate mongod server certificate against ca (mongod server >=2.4 with ssl support required) - sslValidate?: Object; - // Default: true; Server identity checking during SSL - checkServerIdentity?: boolean | Function; - // Array of valid certificates either as Buffers or Strings - sslCA?: Array; - // SSL Certificate revocation list binary buffer - sslCRL?: Buffer; - // SSL Certificate binary buffer - sslCert?: Buffer | string; - // SSL Key file binary buffer - sslKey?: Buffer | string; - // SSL Certificate pass phrase - sslPass?: Buffer | string; - // String containing the server name requested via TLS SNI. - servername?: string; -} - -export interface HighAvailabilityOptions { - // Default: true; Turn on high availability monitoring. - ha?: boolean; - // Default: 10000; The High availability period for replicaset inquiry - haInterval?: number; - // Default: false; - domainsEnabled?: boolean; -} - -// See http://mongodb.github.io/node-mongodb-native/2.2/api/ReadPreference.html -export class ReadPreference { - constructor(mode: string, tags: Object); - mode: string; - tags: any; - options: { maxStalenessSeconds?: number }; // Max Secondary Read Stalleness in Seconds - static PRIMARY: string; - static PRIMARY_PREFERRED: string; - static SECONDARY: string; - static SECONDARY_PREFERRED: string; - static NEAREST: string; - isValid(mode: string): boolean; - static isValid(mode: string): boolean; -} - -// http://mongodb.github.io/node-mongodb-native/2.2/api/Db.html -export interface DbCreateOptions { - - // If the database authentication is dependent on another databaseName. - authSource?: string; - // Default: null;https://docs.mongodb.com/manual/reference/write-concern/#write-concern - w?: number | string; - // The write concern timeout to finish (combining with w option). - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; - // Default: false; Force server to create _id fields instead of client. - forceServerObjectId?: boolean; - // Default: false; Use c++ bson parser. - native_parser?: boolean; - // Serialize functions on any object. - serializeFunctions?: boolean; - // Specify if the BSON serializer should ignore undefined fields. - ignoreUndefined?: boolean; - // Return document results as raw BSON buffers. - raw?: boolean; - // Default: true; Promotes Long values to number if they fit inside the 53 bits resolution. - promoteLongs?: boolean; - // Default: -1 (unlimited); Amount of operations the driver buffers up untill discard any new ones - promoteBuffers?: number; - // the prefered read preference. use 'ReadPreference' class. - readPreference?: ReadPreference | string; - // Default: true; Promotes BSON values to native types where possible, set to false to only receive wrapper types. - promoteValues?: Object; - // Custom primary key factory to generate _id values (see Custom primary keys). - pkFactory?: Object; - // ES6 compatible promise constructor - promiseLibrary?: Object; - // https://docs.mongodb.com/manual/reference/read-concern/#read-concern - readConcern?: { level?: Object }; -} - -// http://mongodb.github.io/node-mongodb-native/2.2/api/Server.html -export interface SocketOptions { - // Reconnect on error. default:false - autoReconnect?: boolean; - // TCP Socket NoDelay option. default:true - noDelay?: boolean; - // TCP KeepAlive on the socket with a X ms delay before start. default:0 - keepAlive?: number; - // TCP Connection timeout setting. default 0 - connectTimeoutMS?: number; - // TCP Socket timeout setting. default 0 - socketTimeoutMS?: number; -} - -// http://mongodb.github.io/node-mongodb-native/2.2/api/Server.html -export interface ServerOptions extends SSLOptions { - // Default: 30; - reconnectTries?: number; - // Default: 1000; - reconnectInterval?: number; - // Default: true; - monitoring?: boolean - socketOptions?: SocketOptions; - // Default: 10000; The High availability period for replicaset inquiry - haInterval?: number; - // Default: false; - domainsEnabled?: boolean; -} - -// http://mongodb.github.io/node-mongodb-native/2.2/api/Mongos.html -export interface MongosOptions extends SSLOptions, HighAvailabilityOptions { - // Default: 15; Cutoff latency point in MS for MongoS proxy selection - acceptableLatencyMS?: number; - socketOptions?: SocketOptions; -} - -// http://mongodb.github.io/node-mongodb-native/2.2/api/ReplSet.html -export interface ReplSetOptions extends SSLOptions, HighAvailabilityOptions { - // The max staleness to secondary reads (values under 10 seconds cannot be guaranteed); - maxStalenessSeconds?: number; - // The name of the replicaset to connect to. - replicaSet?: string; - // Default: 15 ; Range of servers to pick when using NEAREST (lowest ping ms + the latency fence, ex: range of 1 to (1 + 15) ms) - secondaryAcceptableLatencyMS?: number; - connectWithNoPrimary?: boolean; - socketOptions?: SocketOptions; -} - -// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html -export class Db extends EventEmitter { - constructor(databaseName: string, serverConfig: Server | ReplSet | Mongos, options?: DbCreateOptions); - - serverConfig: Server | ReplSet | Mongos; - bufferMaxEntries: number; - databaseName: string; - options: any; - native_parser: boolean; - slaveOk: boolean; - writeConcern: any; - +namespace MongoDB { + export function connect(uri: string, callback: MongoCallback): void; + export function connect(uri: string, options?: MongoClientOptions): Promise; + export function connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; + + export { Binary, Double, Long, Decimal128, MaxKey, MinKey, ObjectID, ObjectId, Timestamp } from 'bson'; + + // Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/MongoClient.html + export class MongoClient { + constructor(); + + static connect(uri: string, callback: MongoCallback): void; + static connect(uri: string, options?: MongoClientOptions): Promise; + static connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; + + connect(uri: string, callback: MongoCallback): void; + connect(uri: string, options?: MongoClientOptions): Promise; + connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; + } + + export interface MongoCallback { + (error: MongoError, result: T): void; + } + + // http://mongodb.github.io/node-mongodb-native/2.1/api/MongoError.html + export class MongoError extends Error { + constructor(message: string); + static create(options: Object): MongoError; + code?: number; + } + + // http://mongodb.github.io/node-mongodb-native/2.2/api/MongoClient.html#.connect + export interface MongoClientOptions extends + DbCreateOptions, + ServerOptions, + MongosOptions, + ReplSetOptions, + SocketOptions, + SSLOptions, + HighAvailabilityOptions { + // The logging level (error/warn/info/debug) + loggerLevel?: string; + // Custom logger object + logger?: Object; + // Default: false; + validateOptions?: Object; + } + + export interface SSLOptions { + // Default:5; Number of connections for each server instance + poolSize?: number; + // Use ssl connection (needs to have a mongod server with ssl support) + ssl?: boolean; + // Default: true; Validate mongod server certificate against ca (mongod server >=2.4 with ssl support required) + sslValidate?: Object; + // Default: true; Server identity checking during SSL + checkServerIdentity?: boolean | Function; + // Array of valid certificates either as Buffers or Strings + sslCA?: Array; + // SSL Certificate revocation list binary buffer + sslCRL?: Buffer; + // SSL Certificate binary buffer + sslCert?: Buffer | string; + // SSL Key file binary buffer + sslKey?: Buffer | string; + // SSL Certificate pass phrase + sslPass?: Buffer | string; + // String containing the server name requested via TLS SNI. + servername?: string; + } + + export interface HighAvailabilityOptions { + // Default: true; Turn on high availability monitoring. + ha?: boolean; + // Default: 10000; The High availability period for replicaset inquiry + haInterval?: number; + // Default: false; + domainsEnabled?: boolean; + } + + // See http://mongodb.github.io/node-mongodb-native/2.2/api/ReadPreference.html + export class ReadPreference { + constructor(mode: string, tags: Object); + mode: string; + tags: any; + options: { maxStalenessSeconds?: number }; // Max Secondary Read Stalleness in Seconds + static PRIMARY: string; + static PRIMARY_PREFERRED: string; + static SECONDARY: string; + static SECONDARY_PREFERRED: string; + static NEAREST: string; + isValid(mode: string): boolean; + static isValid(mode: string): boolean; + } + + // http://mongodb.github.io/node-mongodb-native/2.2/api/Db.html + export interface DbCreateOptions { + + // If the database authentication is dependent on another databaseName. + authSource?: string; + // Default: null;https://docs.mongodb.com/manual/reference/write-concern/#write-concern + w?: number | string; + // The write concern timeout to finish (combining with w option). + wtimeout?: number; + // Specify a journal write concern. + j?: boolean; + // Default: false; Force server to create _id fields instead of client. + forceServerObjectId?: boolean; + // Default: false; Use c++ bson parser. + native_parser?: boolean; + // Serialize functions on any object. + serializeFunctions?: boolean; + // Specify if the BSON serializer should ignore undefined fields. + ignoreUndefined?: boolean; + // Return document results as raw BSON buffers. + raw?: boolean; + // Default: true; Promotes Long values to number if they fit inside the 53 bits resolution. + promoteLongs?: boolean; + // Default: -1 (unlimited); Amount of operations the driver buffers up untill discard any new ones + promoteBuffers?: number; + // the prefered read preference. use 'ReadPreference' class. + readPreference?: ReadPreference | string; + // Default: true; Promotes BSON values to native types where possible, set to false to only receive wrapper types. + promoteValues?: Object; + // Custom primary key factory to generate _id values (see Custom primary keys). + pkFactory?: Object; + // ES6 compatible promise constructor + promiseLibrary?: Object; + // https://docs.mongodb.com/manual/reference/read-concern/#read-concern + readConcern?: { level?: Object }; + } + + // http://mongodb.github.io/node-mongodb-native/2.2/api/Server.html + export interface SocketOptions { + // Reconnect on error. default:false + autoReconnect?: boolean; + // TCP Socket NoDelay option. default:true + noDelay?: boolean; + // TCP KeepAlive on the socket with a X ms delay before start. default:0 + keepAlive?: number; + // TCP Connection timeout setting. default 0 + connectTimeoutMS?: number; + // TCP Socket timeout setting. default 0 + socketTimeoutMS?: number; + } + + // http://mongodb.github.io/node-mongodb-native/2.2/api/Server.html + export interface ServerOptions extends SSLOptions { + // Default: 30; + reconnectTries?: number; + // Default: 1000; + reconnectInterval?: number; + // Default: true; + monitoring?: boolean + socketOptions?: SocketOptions; + // Default: 10000; The High availability period for replicaset inquiry + haInterval?: number; + // Default: false; + domainsEnabled?: boolean; + } + + // http://mongodb.github.io/node-mongodb-native/2.2/api/Mongos.html + export interface MongosOptions extends SSLOptions, HighAvailabilityOptions { + // Default: 15; Cutoff latency point in MS for MongoS proxy selection + acceptableLatencyMS?: number; + socketOptions?: SocketOptions; + } + + // http://mongodb.github.io/node-mongodb-native/2.2/api/ReplSet.html + export interface ReplSetOptions extends SSLOptions, HighAvailabilityOptions { + // The max staleness to secondary reads (values under 10 seconds cannot be guaranteed); + maxStalenessSeconds?: number; + // The name of the replicaset to connect to. + replicaSet?: string; + // Default: 15 ; Range of servers to pick when using NEAREST (lowest ping ms + the latency fence, ex: range of 1 to (1 + 15) ms) + secondaryAcceptableLatencyMS?: number; + connectWithNoPrimary?: boolean; + socketOptions?: SocketOptions; + } + + // Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html + export class Db extends EventEmitter { + constructor(databaseName: string, serverConfig: Server | ReplSet | Mongos, options?: DbCreateOptions); + + serverConfig: Server | ReplSet | Mongos; + bufferMaxEntries: number; + databaseName: string; + options: any; + native_parser: boolean; + slaveOk: boolean; + writeConcern: any; + + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser + addUser(username: string, password: string, callback: MongoCallback): void; + addUser(username: string, password: string, options?: DbAddUserOptions): Promise; + addUser(username: string, password: string, options: DbAddUserOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#admin + admin(): Admin; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#authenticate + authenticate(userName: string, password: string, callback: MongoCallback): void; + authenticate(userName: string, password: string, options?: { authMechanism: string }): Promise; + authenticate(userName: string, password: string, options: { authMechanism: string }, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#close + close(callback: MongoCallback): void; + close(forceClose?: boolean): Promise; + close(forceClose: boolean, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection + collection(name: string): Collection; + collection(name: string, callback: MongoCallback>): Collection; + collection(name: string, options: DbCollectionOptions, callback: MongoCallback>): Collection; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collections + collections(): Promise[]>; + collections(callback: MongoCallback[]>): void; + //http://mongodb.github.io/node-mongodb-native/2.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; + //http://mongodb.github.io/node-mongodb-native/2.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/2.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; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#db + db(dbName: string): Db; + db(dbName: string, options: { noListener?: boolean, returnNonCachedInstance?: boolean }): Db; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropCollection + dropCollection(name: string): Promise; + dropCollection(name: string, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropDatabase + dropDatabase(): Promise; + dropDatabase(callback: MongoCallback): void; + + //deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#ensureIndex + // ensureIndex(collectionName: any, fieldOrSpec: any, options: IndexOptions, callback: Function): void; + //deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#eval + // eval(code: any, parameters: any[], options?: any, callback?: MongoCallback): void; + + //http://mongodb.github.io/node-mongodb-native/2.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; + // http://mongodb.github.io/node-mongodb-native/2.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/2.1/api/Db.html#listCollections + listCollections(filter: Object, options?: { batchSize?: number, readPreference?: ReadPreference | string }): CommandCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#logout + logout(callback: MongoCallback): void; + logout(options?: { dbName?: string }): Promise; + logout(options: { dbName?: string }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#open + open(): Promise; + open(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#removeUser + removeUser(username: string, callback: MongoCallback): void; + removeUser(username: string, options?: { w?: number | string, wtimeout?: number, j?: boolean }): Promise; + removeUser(username: string, options: { w?: number | string, wtimeout?: number, j?: boolean }, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#renameCollection + renameCollection(fromCollection: string, toCollection: string, callback: MongoCallback>): void; + renameCollection(fromCollection: string, toCollection: string, options?: { dropTarget?: boolean }): Promise>; + renameCollection(fromCollection: string, toCollection: string, options: { dropTarget?: boolean }, callback: MongoCallback>): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#stats + stats(callback: MongoCallback): void; + stats(options?: { scale?: number }): Promise; + stats(options: { scale?: number }, callback: MongoCallback): void; + } + + // Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html + export class Server extends EventEmitter { + constructor(host: string, port: number, options?: ServerOptions); + + connections(): Array; + } + + // Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html + export class ReplSet extends EventEmitter { + constructor(servers: Array, options?: ReplSetOptions); + + connections(): Array; + } + + // Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html + export class Mongos extends EventEmitter { + constructor(servers: Array, options?: MongosOptions); + + connections(): Array; + } + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser - addUser(username: string, password: string, callback: MongoCallback): void; - addUser(username: string, password: string, options?: DbAddUserOptions): Promise; - addUser(username: string, password: string, options: DbAddUserOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#admin - admin(): Admin; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#authenticate - authenticate(userName: string, password: string, callback: MongoCallback): void; - authenticate(userName: string, password: string, options?: { authMechanism: string }): Promise; - authenticate(userName: string, password: string, options: { authMechanism: string }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#close - close(callback: MongoCallback): void; - close(forceClose?: boolean): Promise; - close(forceClose: boolean, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection - collection(name: string): Collection; - collection(name: string, callback: MongoCallback>): Collection; - collection(name: string, options: DbCollectionOptions, callback: MongoCallback>): Collection; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collections - collections(): Promise[]>; - collections(callback: MongoCallback[]>): void; - //http://mongodb.github.io/node-mongodb-native/2.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; + export interface DbAddUserOptions { + w?: string | number; + wtimeout?: number; + j?: boolean; + customData?: Object; + roles?: Object[]; + } + //http://mongodb.github.io/node-mongodb-native/2.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/2.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; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#db - db(dbName: string): Db; - db(dbName: string, options: { noListener?: boolean, returnNonCachedInstance?: boolean }): Db; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropCollection - dropCollection(name: string): Promise; - dropCollection(name: string, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropDatabase - dropDatabase(): Promise; - dropDatabase(callback: MongoCallback): void; - - //deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#ensureIndex - // ensureIndex(collectionName: any, fieldOrSpec: any, options: IndexOptions, callback: Function): void; - //deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#eval - // eval(code: any, parameters: any[], options?: any, callback?: MongoCallback): void; - - //http://mongodb.github.io/node-mongodb-native/2.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; - // http://mongodb.github.io/node-mongodb-native/2.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/2.1/api/Db.html#listCollections - listCollections(filter: Object, options?: { batchSize?: number, readPreference?: ReadPreference | string }): CommandCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#logout - logout(callback: MongoCallback): void; - logout(options?: { dbName?: string }): Promise; - logout(options: { dbName?: string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#open - open(): Promise; - open(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#removeUser - removeUser(username: string, callback: MongoCallback): void; - removeUser(username: string, options?: { w?: number | string, wtimeout?: number, j?: boolean }): Promise; - removeUser(username: string, options: { w?: number | string, wtimeout?: number, j?: boolean }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#renameCollection - renameCollection(fromCollection: string, toCollection: string, callback: MongoCallback>): void; - renameCollection(fromCollection: string, toCollection: string, options?: { dropTarget?: boolean }): Promise>; - renameCollection(fromCollection: string, toCollection: string, options: { dropTarget?: boolean }, callback: MongoCallback>): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#stats - stats(callback: MongoCallback): void; - stats(options?: { scale?: number }): Promise; - stats(options: { scale?: number }, callback: MongoCallback): void; -} - -// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html -export class Server extends EventEmitter { - constructor(host: string, port: number, options?: ServerOptions); - - connections(): Array; -} - -// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html -export class ReplSet extends EventEmitter { - constructor(servers: Array, options?: ReplSetOptions); - - connections(): Array; -} - -// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html -export class Mongos extends EventEmitter { - constructor(servers: Array, options?: MongosOptions); - - connections(): Array; -} - -// http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser -export interface DbAddUserOptions { - w?: string | number; - wtimeout?: number; - j?: boolean; - customData?: Object; - roles?: Object[]; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection -export interface CollectionCreateOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; - raw?: boolean; - pkFactory?: Object; - readPreference?: ReadPreference | string; - serializeFunctions?: boolean; - strict?: boolean; - capped?: boolean; - size?: number; - max?: number; - autoIndexId?: boolean; -} - -// http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection -export interface DbCollectionOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; - raw?: boolean; - pkFactory?: Object; - readPreference?: ReadPreference | string; - serializeFunctions?: boolean; - strict?: boolean; - readConcern?: { level: Object }; -} - -//http://mongodb.github.io/node-mongodb-native/2.2/api/Db.html#createIndex -export interface IndexOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; - // Creates an unique index. - unique?: boolean; - // Creates a sparse index. - sparse?: boolean; - // Creates the index in the background, yielding whenever possible. - background?: boolean; - // A unique index cannot be created on a key that has pre-existing duplicate values. - // If you would like to create the index anyway, keeping the first document the database indexes and - // deleting all subsequent documents that have duplicate value - dropDups?: boolean; - // For geo spatial indexes set the lower bound for the co-ordinates. - min?: number; - // For geo spatial indexes set the high bound for the co-ordinates. - max?: number; - // Specify the format version of the indexes. - v?: number; - // Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) - expireAfterSeconds?: number; - // Override the auto generated index name (useful if the resulting name is larger than 128 bytes) - name?: string; - // Creates a partial index based on the given filter object (MongoDB 3.2 or higher) - partialFilterExpression?: any; -} - -// http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html -export interface Admin { - // http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser - addUser(username: string, password: string, callback: MongoCallback): void; - addUser(username: string, password: string, options?: AddUserOptions): Promise; - addUser(username: string, password: string, options: AddUserOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#authenticate - authenticate(username: string, callback: MongoCallback): void; - authenticate(username: string, password?: string): Promise; - authenticate(username: string, password: string, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#buildInfo - buildInfo(): Promise; - buildInfo(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.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; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#listDatabases - listDatabases(): Promise; - listDatabases(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#logout - logout(): Promise; - logout(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#ping - ping(): Promise; - ping(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingInfo - profilingInfo(): Promise; - profilingInfo(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingLevel - profilingLevel(): Promise; - profilingLevel(callback: MongoCallback): void; + export interface CollectionCreateOptions { + w?: number | string; + wtimeout?: number; + j?: boolean; + raw?: boolean; + pkFactory?: Object; + readPreference?: ReadPreference | string; + serializeFunctions?: boolean; + strict?: boolean; + capped?: boolean; + size?: number; + max?: number; + autoIndexId?: boolean; + } + + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection + export interface DbCollectionOptions { + w?: number | string; + wtimeout?: number; + j?: boolean; + raw?: boolean; + pkFactory?: Object; + readPreference?: ReadPreference | string; + serializeFunctions?: boolean; + strict?: boolean; + readConcern?: { level: Object }; + } + + //http://mongodb.github.io/node-mongodb-native/2.2/api/Db.html#createIndex + export interface IndexOptions { + // The write concern. + w?: number | string; + // The write concern timeout. + wtimeout?: number; + // Specify a journal write concern. + j?: boolean; + // Creates an unique index. + unique?: boolean; + // Creates a sparse index. + sparse?: boolean; + // Creates the index in the background, yielding whenever possible. + background?: boolean; + // A unique index cannot be created on a key that has pre-existing duplicate values. + // If you would like to create the index anyway, keeping the first document the database indexes and + // deleting all subsequent documents that have duplicate value + dropDups?: boolean; + // For geo spatial indexes set the lower bound for the co-ordinates. + min?: number; + // For geo spatial indexes set the high bound for the co-ordinates. + max?: number; + // Specify the format version of the indexes. + v?: number; + // Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) + expireAfterSeconds?: number; + // Override the auto generated index name (useful if the resulting name is larger than 128 bytes) + name?: string; + // Creates a partial index based on the given filter object (MongoDB 3.2 or higher) + partialFilterExpression?: any; + } + + // http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html + export interface Admin { + // http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser + addUser(username: string, password: string, callback: MongoCallback): void; + addUser(username: string, password: string, options?: AddUserOptions): Promise; + addUser(username: string, password: string, options: AddUserOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#authenticate + authenticate(username: string, callback: MongoCallback): void; + authenticate(username: string, password?: string): Promise; + authenticate(username: string, password: string, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#buildInfo + buildInfo(): Promise; + buildInfo(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.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; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#listDatabases + listDatabases(): Promise; + listDatabases(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#logout + logout(): Promise; + logout(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#ping + ping(): Promise; + ping(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingInfo + profilingInfo(): Promise; + profilingInfo(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingLevel + profilingLevel(): Promise; + profilingLevel(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser + removeUser(username: string, callback: MongoCallback): void; + removeUser(username: string, options?: FSyncOptions): Promise; + removeUser(username: string, options: FSyncOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#replSetGetStatus + replSetGetStatus(): Promise; + replSetGetStatus(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverInfo + serverInfo(): Promise; + serverInfo(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverStatus + serverStatus(): Promise; + serverStatus(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#setProfilingLevel + setProfilingLevel(level: string): Promise; + setProfilingLevel(level: string, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.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; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser + export interface AddUserOptions { + w?: number | string; + wtimeout?: number; + j?: boolean; + fsync: boolean; + customData?: Object; + roles?: Object[] + } + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser - removeUser(username: string, callback: MongoCallback): void; - removeUser(username: string, options?: FSyncOptions): Promise; - removeUser(username: string, options: FSyncOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#replSetGetStatus - replSetGetStatus(): Promise; - replSetGetStatus(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverInfo - serverInfo(): Promise; - serverInfo(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverStatus - serverStatus(): Promise; - serverStatus(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#setProfilingLevel - setProfilingLevel(level: string): Promise; - setProfilingLevel(level: string, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.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; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser -export interface AddUserOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; - fsync: boolean; - customData?: Object; - roles?: Object[] -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser -export interface FSyncOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; - fsync?: boolean -} - -// Documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html -export interface Collection { - // Get the collection name. - collectionName: string; - // Get the full collection namespace. - namespace: string; - // The current write concern values. - writeConcern: any; - // The current read concern values. - readConcern: any; - // Get current index hint for collection. - hint: any; + export interface FSyncOptions { + w?: number | string; + wtimeout?: number; + j?: boolean; + fsync?: boolean + } + + // Documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html + export interface Collection { + // Get the collection name. + collectionName: string; + // Get the full collection namespace. + namespace: string; + // The current write concern values. + writeConcern: any; + // The current read concern values. + readConcern: any; + // Get current index hint for collection. + hint: any; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate + aggregate(pipeline: Object[], callback: MongoCallback): AggregationCursor; + aggregate(pipeline: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback): AggregationCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite + bulkWrite(operations: Object[], callback: MongoCallback): void; + bulkWrite(operations: Object[], options?: CollectionBluckWriteOptions): Promise; + bulkWrite(operations: Object[], options: CollectionBluckWriteOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#count + count(query: Object, callback: MongoCallback): void; + count(query: Object, options?: MongoCountPreferences): Promise; + count(query: Object, options: MongoCountPreferences, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndex + createIndex(fieldOrSpec: string | any, callback: MongoCallback): void; + createIndex(fieldOrSpec: string | any, options?: IndexOptions): Promise; + createIndex(fieldOrSpec: string | any, options: IndexOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndexes and http://docs.mongodb.org/manual/reference/command/createIndexes/ + createIndexes(indexSpecs: Object[]): Promise; + createIndexes(indexSpecs: Object[], callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany + deleteMany(filter: Object, callback: MongoCallback): void; + deleteMany(filter: Object, options?: CollectionOptions): Promise; + deleteMany(filter: Object, options: CollectionOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteOne + deleteOne(filter: Object, callback: MongoCallback): void; + deleteOne(filter: Object, options?: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }): Promise; + deleteOne(filter: Object, options: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#distinct + distinct(key: string, query: Object, callback: MongoCallback): void; + distinct(key: string, query: Object, options?: { readPreference?: ReadPreference | string }): Promise; + distinct(key: string, query: Object, options: { readPreference?: ReadPreference | string }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#drop + drop(): Promise; + drop(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndex + dropIndex(indexName: string, callback: MongoCallback): void; + dropIndex(indexName: string, options?: CollectionOptions): Promise; + dropIndex(indexName: string, options: CollectionOptions, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndexes + dropIndexes(): Promise; + dropIndexes(callback?: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#find + find(query?: Object): Cursor; + /** @deprecated */ + find(query: Object, fields?: Object, skip?: number, limit?: number, timeout?: number): Cursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne + findOne(filter: Object, callback: MongoCallback): void; + findOne(filter: Object, options?: FindOneOptions): Promise; + findOne(filter: Object, options: FindOneOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndDelete + findOneAndDelete(filter: Object, callback: MongoCallback>): void; + findOneAndDelete(filter: Object, options?: { projection?: Object, sort?: Object, maxTimeMS?: number }): Promise>; + findOneAndDelete(filter: Object, options: { projection?: Object, sort?: Object, maxTimeMS?: number }, callback: MongoCallback>): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace + findOneAndReplace(filter: Object, replacement: Object, callback: MongoCallback>): void; + findOneAndReplace(filter: Object, replacement: Object, options?: FindOneAndReplaceOption): Promise>; + findOneAndReplace(filter: Object, replacement: Object, options: FindOneAndReplaceOption, callback: MongoCallback>): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndUpdate + findOneAndUpdate(filter: Object, update: Object, callback: MongoCallback>): void; + findOneAndUpdate(filter: Object, update: Object, options?: FindOneAndReplaceOption): Promise>; + findOneAndUpdate(filter: Object, update: Object, options: FindOneAndReplaceOption, callback: MongoCallback>): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch + 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/2.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/2.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; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexes + indexes(): Promise; + indexes(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexExists + indexExists(indexes: string | string[]): Promise; + indexExists(indexes: string | string[], callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexInformation + indexInformation(callback: MongoCallback): void; + indexInformation(options?: { full: boolean }): Promise; + indexInformation(options: { full: boolean }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeOrderedBulkOp + initializeOrderedBulkOp(options?: CollectionOptions): OrderedBulkOperation; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeUnorderedBulkOp + initializeUnorderedBulkOp(options?: CollectionOptions): UnorderedBulkOperation; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne + /** @deprecated Use insertOne, insertMany or bulkWrite */ + insert(docs: Object, callback: MongoCallback): void; + /** @deprecated Use insertOne, insertMany or bulkWrite */ + insert(docs: Object, options?: CollectionInsertOneOptions): Promise; + /** @deprecated Use insertOne, insertMany or bulkWrite */ + insert(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertMany + insertMany(docs: Object[], callback: MongoCallback): void; + insertMany(docs: Object[], options?: CollectionInsertManyOptions): Promise; + insertMany(docs: Object[], options: CollectionInsertManyOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne + insertOne(docs: Object, callback: MongoCallback): void; + insertOne(docs: Object, options?: CollectionInsertOneOptions): Promise; + insertOne(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#isCapped + isCapped(): Promise; + isCapped(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#listIndexes + listIndexes(options?: { batchSize?: number, readPreference?: ReadPreference | string }): CommandCursor; + //http://mongodb.github.io/node-mongodb-native/2.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; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#options + options(): Promise; + options(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#parallelCollectionScan + parallelCollectionScan(callback: MongoCallback[]>): void; + parallelCollectionScan(options?: ParallelCollectionScanOptions): Promise[]>; + parallelCollectionScan(options: ParallelCollectionScanOptions, callback: MongoCallback[]>): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#reIndex + reIndex(): Promise; + reIndex(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#remove + /** @deprecated Use use deleteOne, deleteMany or bulkWrite */ + remove(selector: Object, callback: MongoCallback): void; + /** @deprecated Use use deleteOne, deleteMany or bulkWrite */ + remove(selector: Object, options?: CollectionOptions & { single?: boolean }): Promise; + /** @deprecated Use use deleteOne, deleteMany or bulkWrite */ + remove(selector: Object, options?: CollectionOptions & { single?: boolean }, callback?: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#rename + rename(newName: string, callback: MongoCallback>): void; + rename(newName: string, options?: { dropTarget?: boolean }): Promise>; + rename(newName: string, options: { dropTarget?: boolean }, callback: MongoCallback>): void; + //http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#replaceOne + replaceOne(filter: Object, doc: Object, callback: MongoCallback }>): void; + replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise }>; + replaceOne(filter: Object, doc: Object, options: ReplaceOneOptions, callback: MongoCallback }>): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#save + /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ + save(doc: Object, callback: MongoCallback): void; + /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ + save(doc: Object, options?: CollectionOptions): Promise; + /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ + save(doc: Object, options: CollectionOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#stats + stats(callback: MongoCallback): void; + stats(options?: { scale: number }): Promise; + stats(options: { scale: number }, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#update + /** @deprecated use updateOne, updateMany or bulkWrite */ + update(filter: Object, update: Object, callback: MongoCallback): void; + /** @deprecated use updateOne, updateMany or bulkWrite */ + update(filter: Object, update: Object, options?: ReplaceOneOptions & { multi?: boolean }): Promise; + /** @deprecated use updateOne, updateMany or bulkWrite */ + update(filter: Object, update: Object, options: ReplaceOneOptions & { multi?: boolean }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateMany + updateMany(filter: Object, update: Object, callback: MongoCallback): void; + updateMany(filter: Object, update: Object, options?: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean; }): Promise; + updateMany(filter: Object, update: Object, options: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean; }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateOne + updateOne(filter: Object, update: Object, callback: MongoCallback): void; + updateOne(filter: Object, update: Object, options?: ReplaceOneOptions): Promise; + updateOne(filter: Object, update: Object, options: ReplaceOneOptions, callback: MongoCallback): void; + } + + // Documentation: http://docs.mongodb.org/manual/reference/command/collStats/ + //TODO complete this + export interface CollStats { + // Namespace. + ns: string; + // Number of documents. + count: number; + // Collection size in bytes. + size: number; + // Average object size in bytes. + avgObjSize: number; + // (Pre)allocated space for the collection in bytes. + storageSize: number; + // Number of extents (contiguously allocated chunks of datafile space). + numExtents: number; + // Number of indexes. + nindexes: number; + // Size of the most recently created extent in bytes. + lastExtentSize: number; + // Padding can speed up updates if documents grow. + paddingFactor: number; + userFlags: number; + // Total index size in bytes. + totalIndexSize: number; + // Size of specific indexes in bytes. + indexSizes: { + _id_: number; + username: number; + }; + capped: boolean; + maxSize: boolean; + wiredTiger: any; + indexDetails: any; + ok: number; + } + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate - aggregate(pipeline: Object[], callback: MongoCallback): AggregationCursor; - aggregate(pipeline: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback): AggregationCursor; + export interface CollectionAggregationOptions { + readPreference?: ReadPreference | string; + // Return the query as cursor, on 2.6 > it returns as a real cursor + // on pre 2.6 it returns as an emulated cursor. + cursor?: { batchSize: number }; + // Explain returns the aggregation execution plan (requires mongodb 2.6 >). + explain?: boolean; + // lets the server know if it can use disk to store + // temporary results for the aggregation (requires mongodb 2.6 >). + allowDiskUse?: boolean; + // specifies a cumulative time limit in milliseconds for processing operations + // on the cursor. MongoDB interrupts the operation at the earliest following interrupt point. + maxTimeMS?: number; + // Allow driver to bypass schema validation in MongoDB 3.2 or higher. + bypassDocumentValidation?: boolean; + } + + //http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#insertMany + export interface CollectionInsertManyOptions { + // The write concern. + w?: number | string; + // The write concern timeout. + wtimeout?: number; + // Specify a journal write concern. + j?: boolean; + // Serialize functions on any object. + serializeFunctions?: boolean; + //Force server to assign _id values instead of driver. + forceServerObjectId?: boolean; + // Allow driver to bypass schema validation in MongoDB 3.2 or higher. + bypassDocumentValidation?: boolean; + // If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails. + ordered?: boolean; + } + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite - bulkWrite(operations: Object[], callback: MongoCallback): void; - bulkWrite(operations: Object[], options?: CollectionBluckWriteOptions): Promise; - bulkWrite(operations: Object[], options: CollectionBluckWriteOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#count - count(query: Object, callback: MongoCallback): void; - count(query: Object, options?: MongoCountPreferences): Promise; - count(query: Object, options: MongoCountPreferences, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndex - createIndex(fieldOrSpec: string | any, callback: MongoCallback): void; - createIndex(fieldOrSpec: string | any, options?: IndexOptions): Promise; - createIndex(fieldOrSpec: string | any, options: IndexOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndexes and http://docs.mongodb.org/manual/reference/command/createIndexes/ - createIndexes(indexSpecs: Object[]): Promise; - createIndexes(indexSpecs: Object[], callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany - deleteMany(filter: Object, callback: MongoCallback): void; - deleteMany(filter: Object, options?: CollectionOptions): Promise; - deleteMany(filter: Object, options: CollectionOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteOne - deleteOne(filter: Object, callback: MongoCallback): void; - deleteOne(filter: Object, options?: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }): Promise; - deleteOne(filter: Object, options: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#distinct - distinct(key: string, query: Object, callback: MongoCallback): void; - distinct(key: string, query: Object, options?: { readPreference?: ReadPreference | string }): Promise; - distinct(key: string, query: Object, options: { readPreference?: ReadPreference | string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#drop - drop(): Promise; - drop(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndex - dropIndex(indexName: string, callback: MongoCallback): void; - dropIndex(indexName: string, options?: CollectionOptions): Promise; - dropIndex(indexName: string, options: CollectionOptions, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndexes - dropIndexes(): Promise; - dropIndexes(callback?: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#find - find(query?: Object): Cursor; - /** @deprecated */ - find(query: Object, fields?: Object, skip?: number, limit?: number, timeout?: number): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne - findOne(filter: Object, callback: MongoCallback): void; - findOne(filter: Object, options?: FindOneOptions): Promise; - findOne(filter: Object, options: FindOneOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndDelete - findOneAndDelete(filter: Object, callback: MongoCallback>): void; - findOneAndDelete(filter: Object, options?: { projection?: Object, sort?: Object, maxTimeMS?: number }): Promise>; - findOneAndDelete(filter: Object, options: { projection?: Object, sort?: Object, maxTimeMS?: number }, callback: MongoCallback>): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace - findOneAndReplace(filter: Object, replacement: Object, callback: MongoCallback>): void; - findOneAndReplace(filter: Object, replacement: Object, options?: FindOneAndReplaceOption): Promise>; - findOneAndReplace(filter: Object, replacement: Object, options: FindOneAndReplaceOption, callback: MongoCallback>): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndUpdate - findOneAndUpdate(filter: Object, update: Object, callback: MongoCallback>): void; - findOneAndUpdate(filter: Object, update: Object, options?: FindOneAndReplaceOption): Promise>; - findOneAndUpdate(filter: Object, update: Object, options: FindOneAndReplaceOption, callback: MongoCallback>): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch - 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/2.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/2.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; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexes - indexes(): Promise; - indexes(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexExists - indexExists(indexes: string | string[]): Promise; - indexExists(indexes: string | string[], callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexInformation - indexInformation(callback: MongoCallback): void; - indexInformation(options?: { full: boolean }): Promise; - indexInformation(options: { full: boolean }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeOrderedBulkOp - initializeOrderedBulkOp(options?: CollectionOptions): OrderedBulkOperation; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeUnorderedBulkOp - initializeUnorderedBulkOp(options?: CollectionOptions): UnorderedBulkOperation; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne - /** @deprecated Use insertOne, insertMany or bulkWrite */ - insert(docs: Object, callback: MongoCallback): void; - /** @deprecated Use insertOne, insertMany or bulkWrite */ - insert(docs: Object, options?: CollectionInsertOneOptions): Promise; - /** @deprecated Use insertOne, insertMany or bulkWrite */ - insert(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertMany - insertMany(docs: Object[], callback: MongoCallback): void; - insertMany(docs: Object[], options?: CollectionInsertManyOptions): Promise; - insertMany(docs: Object[], options: CollectionInsertManyOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne - insertOne(docs: Object, callback: MongoCallback): void; - insertOne(docs: Object, options?: CollectionInsertOneOptions): Promise; - insertOne(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#isCapped - isCapped(): Promise; - isCapped(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#listIndexes - listIndexes(options?: { batchSize?: number, readPreference?: ReadPreference | string }): CommandCursor; - //http://mongodb.github.io/node-mongodb-native/2.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; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#options - options(): Promise; - options(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#parallelCollectionScan - parallelCollectionScan(callback: MongoCallback[]>): void; - parallelCollectionScan(options?: ParallelCollectionScanOptions): Promise[]>; - parallelCollectionScan(options: ParallelCollectionScanOptions, callback: MongoCallback[]>): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#reIndex - reIndex(): Promise; - reIndex(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#remove - /** @deprecated Use use deleteOne, deleteMany or bulkWrite */ - remove(selector: Object, callback: MongoCallback): void; - /** @deprecated Use use deleteOne, deleteMany or bulkWrite */ - remove(selector: Object, options?: CollectionOptions & { single?: boolean }): Promise; - /** @deprecated Use use deleteOne, deleteMany or bulkWrite */ - remove(selector: Object, options?: CollectionOptions & { single?: boolean }, callback?: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#rename - rename(newName: string, callback: MongoCallback>): void; - rename(newName: string, options?: { dropTarget?: boolean }): Promise>; - rename(newName: string, options: { dropTarget?: boolean }, callback: MongoCallback>): void; - //http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#replaceOne - replaceOne(filter: Object, doc: Object, callback: MongoCallback }>): void; - replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise }>; - replaceOne(filter: Object, doc: Object, options: ReplaceOneOptions, callback: MongoCallback }>): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#save - /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ - save(doc: Object, callback: MongoCallback): void; - /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ - save(doc: Object, options?: CollectionOptions): Promise; - /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ - save(doc: Object, options: CollectionOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#stats - stats(callback: MongoCallback): void; - stats(options?: { scale: number }): Promise; - stats(options: { scale: number }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#update - /** @deprecated use updateOne, updateMany or bulkWrite */ - update(filter: Object, update: Object, callback: MongoCallback): void; - /** @deprecated use updateOne, updateMany or bulkWrite */ - update(filter: Object, update: Object, options?: ReplaceOneOptions & { multi?: boolean }): Promise; - /** @deprecated use updateOne, updateMany or bulkWrite */ - update(filter: Object, update: Object, options: ReplaceOneOptions & { multi?: boolean }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateMany - updateMany(filter: Object, update: Object, callback: MongoCallback): void; - updateMany(filter: Object, update: Object, options?: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean; }): Promise; - updateMany(filter: Object, update: Object, options: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean; }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateOne - updateOne(filter: Object, update: Object, callback: MongoCallback): void; - updateOne(filter: Object, update: Object, options?: ReplaceOneOptions): Promise; - updateOne(filter: Object, update: Object, options: ReplaceOneOptions, callback: MongoCallback): void; -} - -// Documentation: http://docs.mongodb.org/manual/reference/command/collStats/ -//TODO complete this -export interface CollStats { - // Namespace. - ns: string; - // Number of documents. - count: number; - // Collection size in bytes. - size: number; - // Average object size in bytes. - avgObjSize: number; - // (Pre)allocated space for the collection in bytes. - storageSize: number; - // Number of extents (contiguously allocated chunks of datafile space). - numExtents: number; - // Number of indexes. - nindexes: number; - // Size of the most recently created extent in bytes. - lastExtentSize: number; - // Padding can speed up updates if documents grow. - paddingFactor: number; - userFlags: number; - // Total index size in bytes. - totalIndexSize: number; - // Size of specific indexes in bytes. - indexSizes: { - _id_: number; - username: number; - }; - capped: boolean; - maxSize: boolean; - wiredTiger: any; - indexDetails: any; - ok: number; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate -export interface CollectionAggregationOptions { - readPreference?: ReadPreference | string; - // Return the query as cursor, on 2.6 > it returns as a real cursor - // on pre 2.6 it returns as an emulated cursor. - cursor?: { batchSize: number }; - // Explain returns the aggregation execution plan (requires mongodb 2.6 >). - explain?: boolean; - // lets the server know if it can use disk to store - // temporary results for the aggregation (requires mongodb 2.6 >). - allowDiskUse?: boolean; - // specifies a cumulative time limit in milliseconds for processing operations - // on the cursor. MongoDB interrupts the operation at the earliest following interrupt point. - maxTimeMS?: number; - // Allow driver to bypass schema validation in MongoDB 3.2 or higher. - bypassDocumentValidation?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#insertMany -export interface CollectionInsertManyOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; - // Serialize functions on any object. - serializeFunctions?: boolean; - //Force server to assign _id values instead of driver. - forceServerObjectId?: boolean; - // Allow driver to bypass schema validation in MongoDB 3.2 or higher. - bypassDocumentValidation?: boolean; - // If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails. - ordered?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite -export interface CollectionBluckWriteOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; - // Serialize functions on any object. - serializeFunctions?: boolean; - // Execute write operation in ordered or unordered fashion. - ordered?: boolean; - // Allow driver to bypass schema validation in MongoDB 3.2 or higher. - bypassDocumentValidation?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~BulkWriteOpResult -export interface BulkWriteOpResultObject { - insertedCount?: number; - matchedCount?: number; - modifiedCount?: number; - deletedCount?: number; - upsertedCount?: number; - insertedIds?: any; - upsertedIds?: any; - result?: any; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#count -export interface MongoCountPreferences { - // The limit of documents to count. - limit?: number; - // The number of documents to skip for the count. - skip?: boolean; - // An index name hint for the query. - hint?: string; - // The preferred read preference - readPreference?: ReadPreference | string; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~deleteWriteOpResult -export interface DeleteWriteOpResultObject { - //The raw result returned from MongoDB, field will vary depending on server version. - result: { + export interface CollectionBluckWriteOptions { + // The write concern. + w?: number | string; + // The write concern timeout. + wtimeout?: number; + // Specify a journal write concern. + j?: boolean; + // Serialize functions on any object. + serializeFunctions?: boolean; + // Execute write operation in ordered or unordered fashion. + ordered?: boolean; + // Allow driver to bypass schema validation in MongoDB 3.2 or higher. + bypassDocumentValidation?: boolean; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~BulkWriteOpResult + export interface BulkWriteOpResultObject { + insertedCount?: number; + matchedCount?: number; + modifiedCount?: number; + deletedCount?: number; + upsertedCount?: number; + insertedIds?: any; + upsertedIds?: any; + result?: any; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#count + export interface MongoCountPreferences { + // The limit of documents to count. + limit?: number; + // The number of documents to skip for the count. + skip?: boolean; + // An index name hint for the query. + hint?: string; + // The preferred read preference + readPreference?: ReadPreference | string; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~deleteWriteOpResult + export interface DeleteWriteOpResultObject { + //The raw result returned from MongoDB, field will vary depending on server version. + result: { + //Is 1 if the command executed correctly. + ok?: number; + //The total count of documents deleted. + n?: number; + } + //The connection object used for the operation. + connection?: any; + //The number of documents deleted. + deletedCount?: number; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~findAndModifyWriteOpResult + export interface FindAndModifyWriteOpResultObject { + //Document returned from findAndModify command. + value?: TSchema; + //The raw lastErrorObject returned from the command. + lastErrorObject?: any; //Is 1 if the command executed correctly. ok?: number; - //The total count of documents deleted. - n?: number; } - //The connection object used for the operation. - connection?: any; - //The number of documents deleted. - deletedCount?: number; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~findAndModifyWriteOpResult -export interface FindAndModifyWriteOpResultObject { - //Document returned from findAndModify command. - value?: TSchema; - //The raw lastErrorObject returned from the command. - lastErrorObject?: any; - //Is 1 if the command executed correctly. - ok?: number; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace -export interface FindOneAndReplaceOption { - projection?: Object; - sort?: Object; - maxTimeMS?: number; - upsert?: boolean; - returnOriginal?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch -export interface GeoHaystackSearchOptions { - readPreference?: ReadPreference | string; - maxDistance?: number; - search?: Object; - limit?: number; -} - -//http://mongodb.github.io/node-mongodb-native/2.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/2.1/api/Code.html -export class Code { - constructor(code: string | Function, scope?: Object) - code: string | Function; - scope: any; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany -export interface CollectionOptions { - //The write concern. - w?: number | string; - //The write concern timeout. - wtimeout?: number; - //Specify a journal write concern. - j?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html -export interface OrderedBulkOperation { - length: number; - //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#execute - execute(callback: MongoCallback): void; - execute(options?: FSyncOptions): Promise; - execute(options: FSyncOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#find - find(selector: Object): FindOperatorsOrdered; - //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#insert - insert(doc: Object): OrderedBulkOperation; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/BulkWriteResult.html -export interface BulkWriteResult { - ok: number; - nInserted: number; - nUpdated: number; - nUpserted: number; - nModified: number; - nRemoved: number; - - getInsertedIds(): Array; - getLastOp(): Object; - getRawResponse(): Object; - getUpsertedIdAt(index: number): Object; - getUpsertedIds(): Array; - getWriteConcernError(): WriteConcernError; - getWriteErrorAt(index: number): WriteError; - getWriteErrorCount(): number; - getWriteErrors(): Array; - hasWriteErrors(): boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/WriteError.html -export interface WriteError { - //Write concern error code. - code: number; - //Write concern error original bulk operation index. - index: number; - //Write concern error message. - errmsg: string; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/WriteConcernError.html -export interface WriteConcernError { - //Write concern error code. - code: number; - //Write concern error message. - errmsg: string; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/FindOperatorsOrdered.html -export interface FindOperatorsOrdered { - delete(): OrderedBulkOperation; - deleteOne(): OrderedBulkOperation; - replaceOne(doc: Object): OrderedBulkOperation; - update(doc: Object): OrderedBulkOperation; - updateOne(doc: Object): OrderedBulkOperation; - upsert(): FindOperatorsOrdered; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html -export interface UnorderedBulkOperation { - //http://mongodb.github.io/node-mongodb-native/2.1/api/lib_bulk_unordered.js.html line 339 - length: number; - //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#execute - execute(callback: MongoCallback): void; - execute(options?: FSyncOptions): Promise; - execute(options: FSyncOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#find - find(selector: Object): FindOperatorsUnordered; - //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#insert - insert(doc: Object): UnorderedBulkOperation; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/FindOperatorsUnordered.html -export interface FindOperatorsUnordered { - length: number; - remove(): UnorderedBulkOperation; - removeOne(): UnorderedBulkOperation; - replaceOne(doc: Object): UnorderedBulkOperation; - update(doc: Object): UnorderedBulkOperation; - updateOne(doc: Object): UnorderedBulkOperation; - upsert(): FindOperatorsUnordered; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne -export interface FindOneOptions { - limit?: number, - sort?: Array | Object, - fields?: Object, - skip?: number, - hint?: Object, - explain?: boolean, - snapshot?: boolean, - timeout?: boolean, - tailable?: boolean, - batchSize?: number, - returnKey?: boolean, - maxScan?: number, - min?: number, - max?: number, - showDiskLoc?: boolean, - comment?: string, - raw?: boolean, - readPreference?: ReadPreference | string, - partial?: boolean, - maxTimeMs?: number -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~insertWriteOpResult -export interface InsertWriteOpResult { - insertedCount: number; - ops: Array; - insertedIds: Array; - connection: any; - result: { ok: number, n: number } -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne -export interface CollectionInsertOneOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; - // Serialize functions on any object. - serializeFunctions?: boolean; - //Force server to assign _id values instead of driver. - forceServerObjectId?: boolean; - //Allow driver to bypass schema validation in MongoDB 3.2 or higher. - bypassDocumentValidation?: boolean -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~insertOneWriteOpResult -export interface InsertOneWriteOpResult { - insertedCount: number; - ops: Array; - insertedId: ObjectID; - connection: any; - result: { ok: number, n: number } -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#parallelCollectionScan -export interface ParallelCollectionScanOptions { - readPreference?: ReadPreference | string; - batchSize?: number; - numCursors?: number; - raw?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#replaceOne -export interface ReplaceOneOptions { - upsert?: boolean; - w?: number | string; - wtimeout?: number; - j?: boolean; - bypassDocumentValidation?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~updateWriteOpResult -export interface UpdateWriteOpResult { - result: { ok: number, n: number, nModified: number }; - connection: any; - matchedCount: number; - modifiedCount: number; - upsertedCount: number; - upsertedId: { _id: ObjectID }; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#mapReduce -export interface MapReduceOptions { - readPreference?: ReadPreference | string; - out?: Object; - query?: Object; - sort?: Object; - limit?: number; - keeptemp?: boolean; - finalize?: Function | string; - scope?: Object; - jsMode?: boolean; - verbose?: boolean; - bypassDocumentValidation?: boolean -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~WriteOpResult -export interface WriteOpResult { - ops: Array; - connection: any; - result: any; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~resultCallback -export type CursorResult = any | void | boolean; - -type Default = any; - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html -export class Cursor extends Readable { - - sortValue: string; - timeout: boolean; - readPreference: ReadPreference; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#addCursorFlag - addCursorFlag(flag: string, value: boolean): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#addQueryModifier - addQueryModifier(name: string, value: boolean): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#batchSize - batchSize(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#clone - clone(): Cursor; // still returns the same type - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#close - close(): Promise; - close(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#comment - comment(value: string): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.2/api/Cursor.html#count - count(callback: MongoCallback): void; - count(applySkipLimit: boolean, callback: MongoCallback): void; - count(options: CursorCommentOptions, callback: MongoCallback): void; - count(applySkipLimit: boolean, options: CursorCommentOptions, callback: MongoCallback): void; - count(applySkipLimit?: boolean, options?: CursorCommentOptions): Promise; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#explain - explain(): Promise; - explain(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#filter - filter(filter: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#forEach - forEach(iterator: IteratorCallback, callback: EndCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#hasNext - hasNext(): Promise; - hasNext(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#hint - hint(hint: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#isClosed - isClosed(): boolean; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#limit - limit(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#map - map(transform: Function): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#max - max(max: number): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxAwaitTimeMS - maxAwaitTimeMS(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxScan - maxScan(maxScan: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxTimeMS - maxTimeMS(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#min - min(min: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#next - next(): Promise; - next(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#project - project(value: Object): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#read - read(size: number): string | Buffer | void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#next - returnKey(returnKey: Object): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#rewind - rewind(): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#setCursorOption - setCursorOption(field: string, value: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#setReadPreference - setReadPreference(readPreference: string | ReadPreference): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#showRecordId - showRecordId(showRecordId: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#skip - skip(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#snapshot - snapshot(snapshot: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#sort - sort(keyOrList: string | Object[] | Object, direction?: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#stream - stream(options?: { transform?: Function }): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#toArray - toArray(): Promise; - toArray(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#unshift - unshift(stream: Buffer | string): void; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#count -export interface CursorCommentOptions { - skip?: number; - limit?: number; - maxTimeMS?: number; - hint?: string; - readPreference?: ReadPreference | string; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~iteratorCallback -export interface IteratorCallback { - (doc: T): void; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~endCallback -export interface EndCallback { - (error: MongoError): void; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#~resultCallback -export type AggregationCursorResult = any | void; -//http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html -export class AggregationCursor extends Readable { - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#batchSize - batchSize(value: number): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#clone - clone(): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#close - close(): Promise; - close(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#each - each(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#explain - explain(): Promise; - explain(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#geoNear - geoNear(document: Object): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#group - group(document: Object): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#isClosed - isClosed(): boolean; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#limit - limit(value: number): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#match - match(document: Object): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#maxTimeMS - maxTimeMS(value: number): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#next - next(): Promise; - next(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#out - out(destination: string): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#project - project(document: Object): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#read - read(size: number): string | Buffer | void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#redact - redact(document: Object): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#rewind - rewind(): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#setEncoding - skip(value: number): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#sort - sort(document: Object): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#toArray - toArray(): Promise; - toArray(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unshift - unshift(stream: Buffer | string): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unwind - unwind(field: string): AggregationCursor; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html -export class CommandCursor extends Readable { - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#batchSize - batchSize(value: number): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#clone - clone(): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#close - close(): Promise; - close(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#each - each(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#isClosed - isClosed(): boolean; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#maxTimeMS - maxTimeMS(value: number): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#next - next(): Promise; - next(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#read - read(size: number): string | Buffer | void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#rewind - rewind(): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#setReadPreference - setReadPreference(readPreference: string | ReadPreference): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#toArray - toArray(): Promise; - toArray(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#unshift - unshift(stream: Buffer | string): void; -} - -// http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html -export class GridFSBucket { - constructor(db: Db, options?: GridFSBucketOptions); - // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#delete - delete(id: ObjectID, callback?: GridFSBucketErrorCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#drop - drop(callback?: GridFSBucketErrorCallback): void; + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace + export interface FindOneAndReplaceOption { + projection?: Object; + sort?: Object; + maxTimeMS?: number; + upsert?: boolean; + returnOriginal?: boolean; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch + export interface GeoHaystackSearchOptions { + readPreference?: ReadPreference | string; + maxDistance?: number; + search?: Object; + limit?: number; + } + + //http://mongodb.github.io/node-mongodb-native/2.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/2.1/api/Code.html + export class Code { + constructor(code: string | Function, scope?: Object) + code: string | Function; + scope: any; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany + export interface CollectionOptions { + //The write concern. + w?: number | string; + //The write concern timeout. + wtimeout?: number; + //Specify a journal write concern. + j?: boolean; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html + export interface OrderedBulkOperation { + length: number; + //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#execute + execute(callback: MongoCallback): void; + execute(options?: FSyncOptions): Promise; + execute(options: FSyncOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#find + find(selector: Object): FindOperatorsOrdered; + //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#insert + insert(doc: Object): OrderedBulkOperation; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/BulkWriteResult.html + export interface BulkWriteResult { + ok: number; + nInserted: number; + nUpdated: number; + nUpserted: number; + nModified: number; + nRemoved: number; + + getInsertedIds(): Array; + getLastOp(): Object; + getRawResponse(): Object; + getUpsertedIdAt(index: number): Object; + getUpsertedIds(): Array; + getWriteConcernError(): WriteConcernError; + getWriteErrorAt(index: number): WriteError; + getWriteErrorCount(): number; + getWriteErrors(): Array; + hasWriteErrors(): boolean; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/WriteError.html + export interface WriteError { + //Write concern error code. + code: number; + //Write concern error original bulk operation index. + index: number; + //Write concern error message. + errmsg: string; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/WriteConcernError.html + export interface WriteConcernError { + //Write concern error code. + code: number; + //Write concern error message. + errmsg: string; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/FindOperatorsOrdered.html + export interface FindOperatorsOrdered { + delete(): OrderedBulkOperation; + deleteOne(): OrderedBulkOperation; + replaceOne(doc: Object): OrderedBulkOperation; + update(doc: Object): OrderedBulkOperation; + updateOne(doc: Object): OrderedBulkOperation; + upsert(): FindOperatorsOrdered; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html + export interface UnorderedBulkOperation { + //http://mongodb.github.io/node-mongodb-native/2.1/api/lib_bulk_unordered.js.html line 339 + length: number; + //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#execute + execute(callback: MongoCallback): void; + execute(options?: FSyncOptions): Promise; + execute(options: FSyncOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#find + find(selector: Object): FindOperatorsUnordered; + //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#insert + insert(doc: Object): UnorderedBulkOperation; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/FindOperatorsUnordered.html + export interface FindOperatorsUnordered { + length: number; + remove(): UnorderedBulkOperation; + removeOne(): UnorderedBulkOperation; + replaceOne(doc: Object): UnorderedBulkOperation; + update(doc: Object): UnorderedBulkOperation; + updateOne(doc: Object): UnorderedBulkOperation; + upsert(): FindOperatorsUnordered; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne + export interface FindOneOptions { + limit?: number, + sort?: Array | Object, + fields?: Object, + skip?: number, + hint?: Object, + explain?: boolean, + snapshot?: boolean, + timeout?: boolean, + tailable?: boolean, + batchSize?: number, + returnKey?: boolean, + maxScan?: number, + min?: number, + max?: number, + showDiskLoc?: boolean, + comment?: string, + raw?: boolean, + readPreference?: ReadPreference | string, + partial?: boolean, + maxTimeMs?: number + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~insertWriteOpResult + export interface InsertWriteOpResult { + insertedCount: number; + ops: Array; + insertedIds: Array; + connection: any; + result: { ok: number, n: number } + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne + export interface CollectionInsertOneOptions { + // The write concern. + w?: number | string; + // The write concern timeout. + wtimeout?: number; + // Specify a journal write concern. + j?: boolean; + // Serialize functions on any object. + serializeFunctions?: boolean; + //Force server to assign _id values instead of driver. + forceServerObjectId?: boolean; + //Allow driver to bypass schema validation in MongoDB 3.2 or higher. + bypassDocumentValidation?: boolean + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~insertOneWriteOpResult + export interface InsertOneWriteOpResult { + insertedCount: number; + ops: Array; + insertedId: ObjectID; + connection: any; + result: { ok: number, n: number } + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#parallelCollectionScan + export interface ParallelCollectionScanOptions { + readPreference?: ReadPreference | string; + batchSize?: number; + numCursors?: number; + raw?: boolean; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#replaceOne + export interface ReplaceOneOptions { + upsert?: boolean; + w?: number | string; + wtimeout?: number; + j?: boolean; + bypassDocumentValidation?: boolean; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~updateWriteOpResult + export interface UpdateWriteOpResult { + result: { ok: number, n: number, nModified: number }; + connection: any; + matchedCount: number; + modifiedCount: number; + upsertedCount: number; + upsertedId: { _id: ObjectID }; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#mapReduce + export interface MapReduceOptions { + readPreference?: ReadPreference | string; + out?: Object; + query?: Object; + sort?: Object; + limit?: number; + keeptemp?: boolean; + finalize?: Function | string; + scope?: Object; + jsMode?: boolean; + verbose?: boolean; + bypassDocumentValidation?: boolean + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~WriteOpResult + export interface WriteOpResult { + ops: Array; + connection: any; + result: any; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~resultCallback + export type CursorResult = any | void | boolean; + + type Default = any; + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html + export class Cursor extends Readable { + + sortValue: string; + timeout: boolean; + readPreference: ReadPreference; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#addCursorFlag + addCursorFlag(flag: string, value: boolean): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#addQueryModifier + addQueryModifier(name: string, value: boolean): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#batchSize + batchSize(value: number): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#clone + clone(): Cursor; // still returns the same type + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#close + close(): Promise; + close(callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#comment + comment(value: string): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.2/api/Cursor.html#count + count(callback: MongoCallback): void; + count(applySkipLimit: boolean, callback: MongoCallback): void; + count(options: CursorCommentOptions, callback: MongoCallback): void; + count(applySkipLimit: boolean, options: CursorCommentOptions, callback: MongoCallback): void; + count(applySkipLimit?: boolean, options?: CursorCommentOptions): Promise; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#explain + explain(): Promise; + explain(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#filter + filter(filter: Object): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#forEach + forEach(iterator: IteratorCallback, callback: EndCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#hasNext + hasNext(): Promise; + hasNext(callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#hint + hint(hint: Object): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#isClosed + isClosed(): boolean; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#limit + limit(value: number): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#map + map(transform: Function): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#max + max(max: number): Cursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxAwaitTimeMS + maxAwaitTimeMS(value: number): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxScan + maxScan(maxScan: Object): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxTimeMS + maxTimeMS(value: number): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#min + min(min: number): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#next + next(): Promise; + next(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#project + project(value: Object): Cursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#read + read(size: number): string | Buffer | void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#next + returnKey(returnKey: Object): Cursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#rewind + rewind(): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#setCursorOption + setCursorOption(field: string, value: Object): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#setReadPreference + setReadPreference(readPreference: string | ReadPreference): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#showRecordId + showRecordId(showRecordId: Object): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#skip + skip(value: number): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#snapshot + snapshot(snapshot: Object): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#sort + sort(keyOrList: string | Object[] | Object, direction?: number): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#stream + stream(options?: { transform?: Function }): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#toArray + toArray(): Promise; + toArray(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#unshift + unshift(stream: Buffer | string): void; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#count + export interface CursorCommentOptions { + skip?: number; + limit?: number; + maxTimeMS?: number; + hint?: string; + readPreference?: ReadPreference | string; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~iteratorCallback + export interface IteratorCallback { + (doc: T): void; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~endCallback + export interface EndCallback { + (error: MongoError): void; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#~resultCallback + export type AggregationCursorResult = any | void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html + export class AggregationCursor extends Readable { + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#batchSize + batchSize(value: number): AggregationCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#clone + clone(): AggregationCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#close + close(): Promise; + close(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#each + each(callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#explain + explain(): Promise; + explain(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#geoNear + geoNear(document: Object): AggregationCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#group + group(document: Object): AggregationCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#isClosed + isClosed(): boolean; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#limit + limit(value: number): AggregationCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#match + match(document: Object): AggregationCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#maxTimeMS + maxTimeMS(value: number): AggregationCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#next + next(): Promise; + next(callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#out + out(destination: string): AggregationCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#project + project(document: Object): AggregationCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#read + read(size: number): string | Buffer | void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#redact + redact(document: Object): AggregationCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#rewind + rewind(): AggregationCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#setEncoding + skip(value: number): AggregationCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#sort + sort(document: Object): AggregationCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#toArray + toArray(): Promise; + toArray(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unshift + unshift(stream: Buffer | string): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unwind + unwind(field: string): AggregationCursor; + } + + //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html + export class CommandCursor extends Readable { + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#batchSize + batchSize(value: number): CommandCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#clone + clone(): CommandCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#close + close(): Promise; + close(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#each + each(callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#isClosed + isClosed(): boolean; + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#maxTimeMS + maxTimeMS(value: number): CommandCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#next + next(): Promise; + next(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#read + read(size: number): string | Buffer | void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#rewind + rewind(): CommandCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#setReadPreference + setReadPreference(readPreference: string | ReadPreference): CommandCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#toArray + toArray(): Promise; + toArray(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#unshift + unshift(stream: Buffer | string): void; + } + + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html + export class GridFSBucket { + constructor(db: Db, options?: GridFSBucketOptions); + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#delete + delete(id: ObjectID, callback?: GridFSBucketErrorCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#drop + drop(callback?: GridFSBucketErrorCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#find + find(filter?: Object, options?: GridFSBucketFindOptions): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openDownloadStream + openDownloadStream(id: ObjectID, options?: { start: number, end: number }): GridFSBucketReadStream; + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openDownloadStreamByName + openDownloadStreamByName(filename: string, options?: { revision: number, start: number, end: number }): GridFSBucketReadStream; + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openUploadStream + openUploadStream(filename: string, options?: GridFSBucketOpenUploadStreamOptions): GridFSBucketWriteStream; + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openUploadStreamWithId + openUploadStreamWithId(id: string | number | Object, filename: string, options?: GridFSBucketOpenUploadStreamOptions): GridFSBucketWriteStream; + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#rename + rename(id: ObjectID, filename: string, callback?: GridFSBucketErrorCallback): void; + } + + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html + export interface GridFSBucketOptions { + bucketName?: string; + chunkSizeBytes?: number; + writeConcern?: Object; + ReadPreference?: Object; + } + + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#~errorCallback + export interface GridFSBucketErrorCallback { + (err?: MongoError): void; + } + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#find - find(filter?: Object, options?: GridFSBucketFindOptions): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openDownloadStream - openDownloadStream(id: ObjectID, options?: { start: number, end: number }): GridFSBucketReadStream; - // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openDownloadStreamByName - openDownloadStreamByName(filename: string, options?: { revision: number, start: number, end: number }): GridFSBucketReadStream; - // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openUploadStream - openUploadStream(filename: string, options?: GridFSBucketOpenUploadStreamOptions): GridFSBucketWriteStream; - // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openUploadStreamWithId - openUploadStreamWithId(id: string | number | Object, filename: string, options?: GridFSBucketOpenUploadStreamOptions): GridFSBucketWriteStream; - // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#rename - rename(id: ObjectID, filename: string, callback?: GridFSBucketErrorCallback): void; + export interface GridFSBucketFindOptions { + batchSize?: number; + limit?: number; + maxTimeMS?: number; + noCursorTimeout?: boolean; + skip?: number; + sort?: Object; + } + + // https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openUploadStream + export interface GridFSBucketOpenUploadStreamOptions { + chunkSizeBytes?: number, + metadata?: Object, + contentType?: string, + aliases?: Array + } + + // https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketReadStream.html + export class GridFSBucketReadStream extends Readable { + constructor(chunks: Collection, files: Collection, readPreference: Object, filter: Object, options?: GridFSBucketReadStreamOptions); + } + + // https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketReadStream.html + export interface GridFSBucketReadStreamOptions { + sort?: number, + skip?: number, + start?: number, + end?: number + } + + // https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketWriteStream.html + export class GridFSBucketWriteStream extends Writable { + constructor(bucket: GridFSBucket, filename: string, options?: GridFSBucketWriteStreamOptions); + } + + // https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketWriteStream.html + export interface GridFSBucketWriteStreamOptions { + id?: string | number | Object, + chunkSizeBytes?: number, + w?: number, + wtimeout?: number, + j?: number + } } -// http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html -export interface GridFSBucketOptions { - bucketName?: string; - chunkSizeBytes?: number; - writeConcern?: Object; - ReadPreference?: Object; -} - -// http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#~errorCallback -export interface GridFSBucketErrorCallback { - (err?: MongoError): void; -} - -// http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#find -export interface GridFSBucketFindOptions { - batchSize?: number; - limit?: number; - maxTimeMS?: number; - noCursorTimeout?: boolean; - skip?: number; - sort?: Object; -} - -// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openUploadStream -export interface GridFSBucketOpenUploadStreamOptions { - chunkSizeBytes?: number, - metadata?: Object, - contentType?: string, - aliases?: Array -} - -// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketReadStream.html -export class GridFSBucketReadStream extends Readable { - constructor(chunks: Collection, files: Collection, readPreference: Object, filter: Object, options?: GridFSBucketReadStreamOptions); -} - -// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketReadStream.html -export interface GridFSBucketReadStreamOptions { - sort?: number, - skip?: number, - start?: number, - end?: number -} - -// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketWriteStream.html -export class GridFSBucketWriteStream extends Writable { - constructor(bucket: GridFSBucket, filename: string, options?: GridFSBucketWriteStreamOptions); -} - -// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketWriteStream.html -export interface GridFSBucketWriteStreamOptions { - id?: string | number | Object, - chunkSizeBytes?: number, - w?: number, - wtimeout?: number, - j?: number -} +export = MongoDB;