///
import { EventEmitter, Readable, Writable } from "../../platform/PlatformTools";
/**
* Creates a new MongoClient instance.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/MongoClient.html
*/
export declare class MongoClient {
constructor();
/**
* Connect to MongoDB using a url as documented at docs.mongodb.org/manual/reference/connection-string/
* Note that for replicasets the replicaSet query parameter is required in the 2.0 driver.
*
* @param url The connection URI string.
* @param callback The command result callback.
*/
static connect(url: string, callback: MongoCallback): void;
/**
* Connect to MongoDB using a url as documented at docs.mongodb.org/manual/reference/connection-string/
* Note that for replicasets the replicaSet query parameter is required in the 2.0 driver.
*
* @param url The connection URI string.
* @param options Optional settings.
*/
static connect(url: string, options?: MongoClientOptions): Promise;
/**
* Connect to MongoDB using a url as documented at docs.mongodb.org/manual/reference/connection-string/
* Note that for replicasets the replicaSet query parameter is required in the 2.0 driver.
*
* @param url The connection URI string.
* @param options Optional settings.
* @param callback The command result callback.
*/
static connect(url: string, options: MongoClientOptions, callback: MongoCallback): void;
/**
* Connect to MongoDB using a url as documented at docs.mongodb.org/manual/reference/connection-string/
* Note that for replicasets the replicaSet query parameter is required in the 2.0 driver.
*
* @param url The connection URI string.
* @param callback The command result callback.
*/
connect(url: string, callback: MongoCallback): void;
/**
* Connect to MongoDB using a url as documented at docs.mongodb.org/manual/reference/connection-string/
* Note that for replicasets the replicaSet query parameter is required in the 2.0 driver.
*
* @param url The connection URI string.
* @param options Optional settings.
*/
connect(url: string, options?: MongoClientOptions): Promise;
/**
* Connect to MongoDB using a url as documented at docs.mongodb.org/manual/reference/connection-string/
* Note that for replicasets the replicaSet query parameter is required in the 2.0 driver.
*
* @param url The connection URI string.
* @param options Optional settings.
* @param callback The command result callback.
*/
connect(url: string, options: MongoClientOptions, callback: MongoCallback): void;
}
/**
* The callback format for results.
*/
export interface MongoCallback {
/**
* @param error An error instance representing the error during the execution.
* @param result The result of execution.
*/
(error: MongoError, result: T): void;
}
export declare class MongoError extends Error {
constructor(message: string);
static create(options: Object): MongoError;
}
/**
* Options for MongoClient#connect method.
*
* @see http://mongodb.github.io/node-mongodb-native/2.2/api/MongoClient.html#.connect
*/
export interface MongoClientOptions {
/**
* The maximum size of the individual server pool.
*/
poolSize?: number;
/**
* Enable SSL connection.
*/
ssl?: boolean;
/**
* SSL Certificate store binary buffer.
*/
sslCA?: Buffer;
/**
* Uri decode the user name and password for authentication.
*/
uri_decode_auth?: boolean;
/**
* A hash of options to set on the db object, see Db constructor.
*/
db?: DbCreateOptions;
/**
* A hash of options to set on the server objects, see Server constructor**.
*/
server?: ServerOptions;
/**
* A hash of options to set on the replSet object, see ReplSet constructor**.
*/
replSet?: ReplSetOptions;
/**
* A hash of options to set on the mongos object, see Mongos constructor**.
*/
mongos?: MongosOptions;
/**
* A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible.
*/
promiseLibrary?: Object;
}
export interface CommandOptions {
/**
* The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED,
* ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
*/
readPreference?: ReadPreference | string;
/**
* Number of milliseconds to wait before aborting the query.
*/
maxTimeMS?: number;
}
/**
* Options for Db class.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html
*/
export interface DbCreateOptions {
/**
* If the database authentication is dependent on another databaseName.
*/
authSource?: string;
/**
* The write concern.
*/
w?: number | string;
/**
* The write concern timeout.
*/
wtimeout?: number;
/**
* Specify a journal write concern.
*/
j?: boolean;
/**
* The current value of the parameter native_parser.
*/
native_parser?: boolean;
/**
* Force server to assign _id values instead of driver.
*/
forceServerObjectId?: 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;
/**
* Promotes Long values to number if they fit inside the 53 bits resolution.
*/
promoteLongs?: boolean;
/**
* Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited.
*/
bufferMaxEntries?: number;
/**
* The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
*/
readPreference?: ReadPreference | string;
/**
* A primary key factory object for generation of custom _id keys.
*/
pkFactory?: Object;
/**
* A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible.
*/
promiseLibrary?: Object;
/**
* Specify a read concern for the collection. (only MongoDB 3.2 or higher supported).
*/
readConcern?: {
level?: Object;
};
}
/**
* Creates a new ReadPreference instance.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/ReadPreference.html
*/
export declare class ReadPreference {
constructor(mode: string, tags: Object);
/**
* The ReadPreference mode as listed above.
*/
mode: string;
/**
* An object representing read preference tags.
*/
tags: any;
/**
* Read from primary only. All operations produce an error (throw an exception where applicable) if primary is unavailable. Cannot be combined with tags (This is the default.).
*/
static PRIMARY: string;
/**
* Read from primary if available, otherwise a secondary.
*/
static PRIMARY_PREFERRED: string;
/**
* Read from secondary if available, otherwise error.
*/
static SECONDARY: string;
/**
* Read from a secondary if available, otherwise read from the primary.
*/
static SECONDARY_PREFERRED: string;
/**
* All modes read from among the nearest candidates, but unlike other modes, NEAREST will include both the primary and all secondaries in the random selection.
*/
static NEAREST: string;
/**
* Validate if a mode is legal.
*/
isValid(mode: string): boolean;
/**
* Validate if a mode is legal.
*/
static isValid(mode: string): boolean;
}
/**
* Creates a new Server instance.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html
*/
export interface SocketOptions {
/**
* Reconnect on error.
*/
autoReconnect?: boolean;
/**
* TCP Socket NoDelay option.
*/
noDelay?: boolean;
/**
* TCP KeepAlive on the socket with a X ms delay before start.
*/
keepAlive?: number;
/**
* TCP Connection timeout setting.
*/
connectTimeoutMS?: number;
/**
* TCP Socket timeout setting.
*/
socketTimeoutMS?: number;
}
/**
* Creates a new Server instance.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html
*/
export interface ServerOptions {
/**
* Number of connections in the connection pool for each server instance, set to 5 as default for legacy reasons.
*/
poolSize?: number;
/**
* Use ssl connection (needs to have a mongod server with ssl support).
*/
ssl?: boolean;
/**
* Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher).
*/
sslValidate?: Object;
/**
* Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function.
*/
checkServerIdentity?: boolean | Function;
/**
* Array of valid certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher).
*/
sslCA?: Array;
/**
* String or buffer containing the certificate we wish to present (needs to have a mongod server with ssl support, 2.4 or higher).
*/
sslCert?: Buffer | string;
/**
* String or buffer containing the certificate private key we wish to present (needs to have a mongod server with ssl support, 2.4 or higher).
*/
sslKey?: Buffer | string;
/**
* String or buffer containing the certificate password (needs to have a mongod server with ssl support, 2.4 or higher).
*/
sslPass?: Buffer | string;
/**
* Socket options.
*/
socketOptions?: SocketOptions;
/**
* Server attempt to reconnect #times.
*/
reconnectTries?: number;
/**
* Server will wait # milliseconds between retries.
*/
reconnectInterval?: number;
}
/**
* Creates a new ReplSet instance.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html
*/
export interface ReplSetOptions {
/**
* Turn on high availability monitoring.
*/
ha?: boolean;
/**
* Time between each replicaset status check.
*/
haInterval?: number;
/**
* The name of the replicaset to connect to.
*/
replicaSet?: string;
/**
* Sets the range of servers to pick when using NEAREST (lowest ping ms + the latency fence, ex: range of 1 to (1 + 15) ms).
*/
secondaryAcceptableLatencyMS?: number;
/**
* Sets if the driver should connect even if no primary is available.
*/
connectWithNoPrimary?: boolean;
/**
* Number of connections in the connection pool for each server instance, set to 5 as default for legacy reasons.
*/
poolSize?: number;
/**
* Use ssl connection (needs to have a mongod server with ssl support).
*/
ssl?: boolean;
/**
* Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher).
*/
sslValidate?: Object;
/**
* Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function.
*/
checkServerIdentity?: boolean | Function;
/**
* Array of valid certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher).
*/
sslCA?: Array;
/**
* String or buffer containing the certificate we wish to present (needs to have a mongod server with ssl support, 2.4 or higher).
*/
sslCert?: Buffer | string;
/**
* String or buffer containing the certificate private key we wish to present (needs to have a mongod server with ssl support, 2.4 or higher).
*/
sslKey?: Buffer | string;
/**
* String or buffer containing the certificate private key we wish to present (needs to have a mongod server with ssl support, 2.4 or higher).
*/
sslPass?: Buffer | string;
/**
* Socket options.
*/
socketOptions?: SocketOptions;
}
/**
* Creates a new Mongos instance.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Mongos.html
*/
export interface MongosOptions {
/**
* Turn on high availability monitoring.
*/
ha?: boolean;
/**
* Time between each replicaset status check.
*/
haInterval?: number;
/**
* Number of connections in the connection pool for each server instance, set to 5 as default for legacy reasons.
*/
poolSize?: number;
/**
* Use ssl connection (needs to have a mongod server with ssl support).
*/
ssl?: boolean;
/**
* Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher).
*/
sslValidate?: Object;
/**
* Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function.
*/
checkServerIdentity?: boolean | Function;
/**
* Array of valid certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher).
*/
sslCA?: Array;
/**
* String or buffer containing the certificate we wish to present (needs to have a mongod server with ssl support, 2.4 or higher).
*/
sslCert?: Buffer | string;
/**
* String or buffer containing the certificate private key we wish to present (needs to have a mongod server with ssl support, 2.4 or higher).
*/
sslKey?: Buffer | string;
/**
* String or buffer containing the certificate password (needs to have a mongod server with ssl support, 2.4 or higher).
*/
sslPass?: Buffer | string;
/**
* Socket options.
*/
socketOptions?: SocketOptions;
}
export interface DbOptions {
/**
* Do not make the db an event listener to the original connection.
*/
noListener?: boolean;
/**
* Control if you want to return a cached instance or have a new one created.
*/
returnNonCachedInstance?: boolean;
}
export interface IndexInformationOptions {
/**
* Returns the full raw index information.
*/
full?: boolean;
/**
* The preferred read preference (ReadPreference.PRIMARY,
* ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY,
* ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
*/
readPreference?: ReadPreference | string;
}
export interface ExecuteDbAdminCommandOptions {
/**
* The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED,
* ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
*/
readPreference?: ReadPreference | string;
}
export interface ListCollectionsOptions {
/**
* The batchSize for the returned command cursor or if pre 2.8 the systems batch collection.
*/
batchSize?: number;
/**
* The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED,
* ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
*/
readPreference?: ReadPreference | string;
}
/**
* Db.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html
*/
export declare class Db extends EventEmitter {
/**
*
* @param databaseName The name of the database this instance represents.
* @param serverConfig The server topology for the database.
* @param options Optional.
*/
constructor(databaseName: string, serverConfig: Server | ReplSet | Mongos, options?: DbCreateOptions);
/**
* Get the current db topology.
*/
serverConfig: Server | ReplSet | Mongos;
/**
* Current bufferMaxEntries value for the database.
*/
bufferMaxEntries: number;
/**
* The name of the database this instance represents.
*/
databaseName: string;
/**
* The options associated with the db instance.
*/
options: any;
/**
* The current value of the parameter native_parser.
*/
native_parser: boolean;
/**
* The current slaveOk value for the db instance.
*/
slaveOk: boolean;
/**
* The current write concern values.
*/
writeConcern: any;
/**
* Add a user to the database.
*
* @param username The username.
* @param password The password.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser
*/
addUser(username: string, password: string, callback: MongoCallback): void;
/**
* Add a user to the database.
*
* @param username The username.
* @param password The password.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser
*/
addUser(username: string, password: string, options?: DbAddUserOptions): Promise;
/**
* Add a user to the database.
*
* @param username The username.
* @param password The password.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser
*/
addUser(username: string, password: string, options: DbAddUserOptions, callback: MongoCallback): void;
/**
* Return the Admin db instance.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#admin
*/
admin(): Admin;
/**
* Authenticate a user against the server.
*
* @param userName The username.
* @param password The password.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#authenticate
*/
authenticate(userName: string, password: string, callback: MongoCallback): void;
/**
* Authenticate a user against the server.
*
* @param userName The username.
* @param password The password.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#authenticate
*/
authenticate(userName: string, password: string, options?: {
authMechanism: string;
}): Promise;
/**
* Authenticate a user against the server.
*
* @param userName The username.
* @param password The password.
* @param password
* @param options
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#authenticate
*/
authenticate(userName: string, password: string, options: {
authMechanism: string;
}, callback: MongoCallback): void;
/**
* Close the db and its underlying connections.
*
* @param callback The result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#close
*/
close(callback: MongoCallback): void;
/**
* Close the db and its underlying connections.
*
* @param forceClose Force close, emitting no events.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#close
*/
close(forceClose?: boolean): Promise;
/**
* Close the db and its underlying connections.
*
* @param forceClose Force close, emitting no events.
* @param callback The result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#close
*/
close(forceClose: boolean, callback: MongoCallback): void;
/**
* Fetch a specific collection (containing the actual collection information). If the application does not use strict mode you can
* can use it without a callback in the following way: var collection = db.collection('mycollection');
*
* @param name The collection name we wish to access.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection
*/
collection(name: string): Collection;
/**
* Fetch a specific collection (containing the actual collection information). If the application does not use strict mode you can
* can use it without a callback in the following way: var collection = db.collection('mycollection');
*
* @param name The collection name we wish to access.
* @param callback The collection result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection
*/
collection(name: string, callback: MongoCallback): Collection;
/**
* Fetch a specific collection (containing the actual collection information). If the application does not use strict mode you can
* can use it without a callback in the following way: var collection = db.collection('mycollection');
*
* @param name The collection name we wish to access.
* @param options Optional settings.
* @param callback The collection result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection
*/
collection(name: string, options: DbCollectionOptions, callback: MongoCallback): Collection;
/**
* Fetch all collections for the current db.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collections
*/
collections(): Promise;
/**
* Fetch all collections for the current db.
*
* @param callback The results callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collections
*/
collections(callback: MongoCallback): void;
/**
* Execute a command.
*
* @param command The command hash.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#command
*/
command(command: Object, callback: MongoCallback): void;
/**
* Execute a command.
*
* @param command The command hash.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#command
*/
command(command: Object, options?: {
readPreference: ReadPreference | string;
}): Promise;
/**
* Execute a command.
*
* @param command The command hash.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#command
*/
command(command: Object, options: {
readPreference: ReadPreference | string;
}, callback: MongoCallback): void;
/**
* Create a new collection on a server with the specified options. Use this to create capped collections.
*
* @param name The collection name we wish to access.
* @param callback The results callback
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection
*/
createCollection(name: string, callback: MongoCallback): void;
/**
* Create a new collection on a server with the specified options. Use this to create capped collections.
*
* @param name The collection name we wish to access.
* @param options Oprional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection
*/
createCollection(name: string, options?: CollectionCreateOptions): Promise;
/**
* Create a new collection on a server with the specified options. Use this to create capped collections.
*
* @param name The collection name we wish to access.
* @param options Optional settings.
* @param callback The results callback
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection
*/
createCollection(name: string, options: CollectionCreateOptions, callback: MongoCallback): void;
/**
* Creates an index on the db and collection collection.
*
* @param name Name of the collection to create the index on.
* @param fieldOrSpec Defines the index.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createIndex
*/
createIndex(name: string, fieldOrSpec: string | Object, callback: MongoCallback): void;
/**
* Creates an index on the db and collection collection.
*
* @param name Name of the collection to create the index on.
* @param fieldOrSpec Defines the index.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createIndex
*/
createIndex(name: string, fieldOrSpec: string | Object, options?: MongodbIndexOptions): Promise;
/**
* Creates an index on the db and collection collection.
*
* @param name Name of the collection to create the index on.
* @param fieldOrSpec Defines the index.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createIndex
*/
createIndex(name: string, fieldOrSpec: string | Object, options: MongodbIndexOptions, callback: MongoCallback): void;
/**
* Create a new Db instance sharing the current socket connections. Be aware that the new db instances are
* related in a parent-child relationship to the original instance so that events are correctly emitted on child
* db instances. Child db instances are cached so performing db('db1') twice will return the same instance.
* You can control these behaviors with the options noListener and returnNonCachedInstance.
*
* @param dbName The name of the database we want to use.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#db
*/
db(dbName: string): Db;
/**
* Create a new Db instance sharing the current socket connections. Be aware that the new db instances are
* related in a parent-child relationship to the original instance so that events are correctly emitted on child
* db instances. Child db instances are cached so performing db('db1') twice will return the same instance.
* You can control these behaviors with the options noListener and returnNonCachedInstance.
*
* @param dbName The name of the database we want to use.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#db
*/
db(dbName: string, options: DbOptions): Db;
/**
* Drop a collection from the database, removing it permanently. New accesses will create a new collection.
*
* @param name Name of collection to drop.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropCollection
*/
dropCollection(name: string): Promise;
/**
* Drop a collection from the database, removing it permanently. New accesses will create a new collection.
*
* @param name Name of collection to drop.
* @param callback The results callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropCollection
*/
dropCollection(name: string, callback: MongoCallback): void;
/**
* Drop a database, removing it permanently from the server.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropDatabase
*/
dropDatabase(): Promise;
/**
* Drop a database, removing it permanently from the server.
*
* @param callback The results callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropDatabase
*/
dropDatabase(callback: MongoCallback): void;
/**
* Runs a command on the database as admin.
*
* @param command The command hash.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#executeDbAdminCommand
*/
executeDbAdminCommand(command: Object, callback: MongoCallback): void;
/**
* Runs a command on the database as admin.
*
* @param command The command hash.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#executeDbAdminCommand
*/
executeDbAdminCommand(command: Object, options?: ExecuteDbAdminCommandOptions): Promise;
/**
* Runs a command on the database as admin.
*
* @param command The command hash.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#executeDbAdminCommand
*/
executeDbAdminCommand(command: Object, options: ExecuteDbAdminCommandOptions, callback: MongoCallback): void;
/**
* Retrieves this collections index info.
*
* @param name The name of the collection.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#indexInformation
*/
indexInformation(name: string, callback: MongoCallback): void;
/**
* Retrieves this collections index info.
*
* @param name The name of the collection.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#indexInformation
*/
indexInformation(name: string, options?: IndexInformationOptions): Promise;
/**
* Retrieves this collections index info.
*
* @param name The name of the collection.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#indexInformation
*/
indexInformation(name: string, options: IndexInformationOptions, callback: MongoCallback): void;
/**
* Get the list of all collection information for the specified db.
*
* @param filter Query to filter collections by.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#listCollections
*/
listCollections(filter: Object, options?: ListCollectionsOptions): CommandCursor;
/**
* Logout user from server, fire off on all connections and remove all auth info.
*
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#logout
*/
logout(callback: MongoCallback): void;
/**
* Logout user from server, fire off on all connections and remove all auth info.
*
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#logout
*/
logout(options?: {
dbName?: string;
}): Promise;
/**
* Logout user from server, fire off on all connections and remove all auth info.
*
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#logout
*/
logout(options: {
dbName?: string;
}, callback: MongoCallback): void;
/**
* Open the database.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#open
*/
open(): Promise;
/**
* Open the database
*
* @param callback Callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#open
*/
open(callback: MongoCallback): void;
/**
*
* @param username
* @param callback
* @see 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;
/**
* Rename a collection.
*
* @param fromCollection Name of current collection to rename.
* @param toCollection New name of of the collection.
* @param callback The results callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#renameCollection
*/
renameCollection(fromCollection: string, toCollection: string, callback: MongoCallback): void;
/**
* Rename a collection.
*
* @param fromCollection Name of current collection to rename.
* @param toCollection New name of of the collection.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#renameCollection
*/
renameCollection(fromCollection: string, toCollection: string, options?: {
dropTarget?: boolean;
}): Promise;
/**
* Rename a collection.
*
* @param fromCollection Name of current collection to rename.
* @param toCollection New name of of the collection.
* @param options Optional settings.
* @param callback The results callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#renameCollection
*/
renameCollection(fromCollection: string, toCollection: string, options: {
dropTarget?: boolean;
}, callback: MongoCallback): void;
/**
* Get all the db statistics.
*
* @param callback The collection result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#stats
*/
stats(callback: MongoCallback): void;
/**
* Get all the db statistics.
*
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#stats
*/
stats(options?: {
scale?: number;
}): Promise;
/**
* Get all the db statistics.
*
* @param options Optional settings.
* @param callback The collection result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#stats
*/
stats(options: {
scale?: number;
}, callback: MongoCallback): void;
}
/**
* Server.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html
*/
export declare class Server extends EventEmitter {
/**
*
* @param host The host for the server, can be either an IP4, IP6 or domain socket style host.
* @param port The server port if IP4.
* @param options Optional.
*/
constructor(host: string, port: number, options?: ServerOptions);
/**
* All raw connections.
*/
connections(): Array;
}
/**
* ReplSet.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html
*/
export declare class ReplSet extends EventEmitter {
/**
*
* @param servers A seedlist of servers participating in the replicaset.
* @param options Optional.
*/
constructor(servers: Array, options?: ReplSetOptions);
/**
* All raw connections
*/
connections(): Array;
}
/**
* Mongos.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Mongos.html
*/
export declare class Mongos extends EventEmitter {
/**
*
* @param servers A seedlist of servers participating in the replicaset.
* @param options Optional.
*/
constructor(servers: Array, options?: MongosOptions);
/**
* All raw connections
*/
connections(): Array;
}
/**
* Creates a new Db instance.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser
*/
export interface DbAddUserOptions {
/**
* The write concern.
*/
w?: string | number;
/**
* The write concern timeout.
*/
wtimeout?: number;
/**
* Specify a journal write concern.
*/
j?: boolean;
/**
* Custom data associated with the user (only Mongodb 2.6 or higher).
*/
customData?: Object;
/**
* Roles associated with the created user (only Mongodb 2.6 or higher).
*/
roles?: Object[];
}
/**
* Creates a new Db instance.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection
*/
export interface CollectionCreateOptions {
/**
* The write concern.
*/
w?: number | string;
/**
* The write concern timeout.
*/
wtimeout?: number;
/**
* Specify a journal write concern.
*/
j?: boolean;
/**
* Return document results as raw BSON buffers.
*/
raw?: boolean;
/**
* A primary key factory object for generation of custom _id keys.
*/
pkFactory?: Object;
/**
* The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
*/
readPreference?: ReadPreference | string;
/**
* Serialize functions on any object.
*/
serializeFunctions?: boolean;
/**
* Returns an error if the collection does not exist.
*/
strict?: boolean;
/**
* Create a capped collection.
*/
capped?: boolean;
/**
* The size of the capped collection in bytes.
*/
size?: number;
/**
* The maximum number of documents in the capped collection.
*/
max?: number;
/**
* Create an index on the _id field of the document, True by default on MongoDB 2.2 or higher off for version < 2.2.
*/
autoIndexId?: boolean;
}
/**
* Creates a new Db instance.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection
*/
export interface DbCollectionOptions {
/**
* The write concern.
*/
w?: number | string;
/**
* The write concern timeout.
*/
wtimeout?: number;
/**
* Specify a journal write concern.
*/
j?: boolean;
/**
* Return document results as raw BSON buffers.
*/
raw?: boolean;
/**
* A primary key factory object for generation of custom _id keys.
*/
pkFactory?: Object;
/**
* The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
*/
readPreference?: ReadPreference | string;
/**
* Serialize functions on any object.
*/
serializeFunctions?: boolean;
/**
* Returns an error if the collection does not exist.
*/
strict?: boolean;
/**
* Specify a read concern for the collection. (only MongoDB 3.2 or higher supported).
*/
readConcern?: {
level: Object;
};
}
/**
* Creates an index on the db and collection collection.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createIndex
*/
export interface MongodbIndexOptions {
/**
* 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 geospatial indexes set the lower bound for the co-ordinates.
*/
min?: number;
/**
* For geospatial 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 autogenerated index name (useful if the resulting name is larger than 128 bytes).
*/
name?: string;
}
/**
* Admin.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html
*/
export interface Admin {
/**
* Add a user to the database.
*
* @param username The username.
* @param password The password.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser
*/
addUser(username: string, password: string, callback: MongoCallback): void;
/**
* Add a user to the database.
*
* @param username The username.
* @param password The password.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser
*/
addUser(username: string, password: string, options?: AddUserOptions): Promise;
/**
* Add a user to the database.
*
* @param username The username.
* @param password The password.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser
*/
addUser(username: string, password: string, options: AddUserOptions, callback: MongoCallback): void;
/**
* Authenticate a user against the server.
*
* @param username The username.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#authenticate
*/
authenticate(username: string, callback: MongoCallback): void;
/**
* Authenticate a user against the server.
*
* @param username The username.
* @param password The password.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#authenticate
*/
authenticate(username: string, password?: string): Promise;
/**
* Authenticate a user against the server.
*
* @param username The username.
* @param password The password.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#authenticate
*/
authenticate(username: string, password: string, callback: MongoCallback): void;
/**
* Retrieve the server information for the current instance of the db client
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#buildInfo
*/
buildInfo(): Promise;
/**
* Retrieve the server information for the current instance of the db client
*
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#buildInfo
*/
buildInfo(callback: MongoCallback): void;
/**
* Execute a command.
*
* @param command The command hash.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#command
*/
command(command: Object, callback: MongoCallback): void;
/**
* Execute a command.
*
* @param command The command hash.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#command
*/
command(command: Object, options?: CommandOptions): Promise;
/**
* Execute a command.
*
* @param command The command hash.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#command
*/
command(command: Object, options: CommandOptions, callback: MongoCallback): void;
/**
* List the available databases.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#listDatabases
*/
listDatabases(): Promise;
/**
* List the available databases.
*
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#listDatabases
*/
listDatabases(callback: MongoCallback): void;
/**
* Logout user from server, fire off on all connections and remove all auth info.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#logout.
*/
logout(): Promise;
/**
* Logout user from server, fire off on all connections and remove all auth info.
*
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#logout.
*/
logout(callback: MongoCallback): void;
/**
* Ping the MongoDB server and retrieve results.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#ping
*/
ping(): Promise;
/**
* Ping the MongoDB server and retrieve results.
*
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#ping
*/
ping(callback: MongoCallback): void;
/**
* Retrive the current profiling information for MongoDB.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingInfo
*/
profilingInfo(): Promise;
/**
* Retrive the current profiling information for MongoDB.
*
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingInfo
*/
profilingInfo(callback: MongoCallback): void;
/**
* Retrieve the current profiling Level for MongoDB.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingLevel
*/
profilingLevel(): Promise;
/**
* Retrieve the current profiling Level for MongoDB.
*
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingLevel
*/
profilingLevel(callback: MongoCallback): void;
/**
* Remove a user from a database.
*
* @param username The username.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser
*/
removeUser(username: string, callback: MongoCallback): void;
/**
* Remove a user from a database.
*
* @param username The username.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser
*/
removeUser(username: string, options?: FSyncOptions): Promise;
/**
* Remove a user from a database.
*
* @param username The username.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser
*/
removeUser(username: string, options: FSyncOptions, callback: MongoCallback): void;
/**
* Get ReplicaSet status.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#replSetGetStatus
*/
replSetGetStatus(): Promise;
/**
* Get ReplicaSet status.
*
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#replSetGetStatus
*/
replSetGetStatus(callback: MongoCallback): void;
/**
* Retrieve the server information for the current
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverInfo
*/
serverInfo(): Promise;
/**
* instance of the db client
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverInfo
* @param callback The command result callback.
*/
serverInfo(callback: MongoCallback): void;
/**
* Retrieve this db's server status.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverStatus
*/
serverStatus(): Promise;
/**
* Retrieve this db's server status.
*
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverStatus
*/
serverStatus(callback: MongoCallback): void;
/**
* Set the current profiling level of MongoDB.
*
* @param level The new profiling level (off, slow_only, all).
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#setProfilingLevel
*/
setProfilingLevel(level: string): Promise;
/**
* Set the current profiling level of MongoDB.
*
* @param level The new profiling level (off, slow_only, all).
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#setProfilingLevel
*/
setProfilingLevel(level: string, callback: MongoCallback): void;
/**
* Validate an existing collection
*
* @param collectionNme The name of the collection to validate.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#validateCollection
*/
validateCollection(collectionNme: string, callback: MongoCallback): void;
/**
* Validate an existing collection
*
* @param collectionNme The name of the collection to validate.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#validateCollection
*/
validateCollection(collectionNme: string, options?: Object): Promise;
/**
* Validate an existing collection
*
* @param collectionNme The name of the collection to validate.
* @param options Optional settings.
* @param callback The command result callback
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#validateCollection
*/
validateCollection(collectionNme: string, options: Object, callback: MongoCallback): void;
}
/**
* Add a user to the database.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser
*/
export interface AddUserOptions {
/**
* The write concern.
*/
w?: number | string;
/**
* The write concern timeout.
*/
wtimeout?: number;
/**
* Specify a journal write concern.
*/
j?: boolean;
/**
* Specify a file sync write concern.
*/
fsync: boolean;
/**
* Custom data associated with the user (only Mongodb 2.6 or higher).
*/
customData?: Object;
/**
* Roles associated with the created user (only Mongodb 2.6 or higher).
*/
roles?: Object[];
}
export interface ListIndexesOptions {
/**
* The batchSize for the returned command cursor or if pre 2.8 the systems batch collection.
*/
batchSize?: number;
/**
* The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED,
* ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
*/
readPreference?: ReadPreference | string;
}
export interface GroupOptions {
/**
* The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED,
* ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
*/
readPreference?: ReadPreference | string;
}
/**
* Remove a user from a database.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser
*/
export interface FSyncOptions {
/**
* The write concern.
*/
w?: number | string;
/**
* The write concern timeout.
*/
wtimeout?: number;
/**
* Specify a journal write concern.
*/
j?: boolean;
/**
* Specify a file sync write concern.
*/
fsync?: boolean;
}
export interface FindOneAndDeleteOptions {
/**
* Limits the fields to return for all matching documents.
*/
projection?: Object;
/**
* Determines which document the operation modifies if the query selects multiple documents.
*/
sort?: Object;
/**
* The maximum amount of time to allow the query to run.
*/
maxTimeMS?: number;
}
/**
* Create a new ObjectID instance.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/ObjectID.html
*/
export declare class ObjectID {
constructor(s?: string | number);
/**
* The generation time of this ObjectId instance.
*/
generationTime: number;
/**
* Creates an ObjectID from a hex string representation of an ObjectID.
*/
static createFromHexString(hexString: string): ObjectID;
/**
* Creates an ObjectID from a second based number, with the rest of the ObjectID zeroed out. Used for comparisons or sorting the ObjectID.
*/
static createFromTime(time: number): ObjectID;
/**
* Checks if a value is a valid bson ObjectId.
*/
static isValid(id: any): boolean;
/**
* Compares the equality of this ObjectID with otherID.
*/
equals(otherID: ObjectID): boolean;
/**
* Generate a 12 byte id buffer used in ObjectID's.
*/
generate(time?: number): string;
/**
* Returns the generation date (accurate up to the second) that this ID was generated.
*
*/
getTimestamp(): Date;
/**
* Return the ObjectID id as a 24 byte hex string representation.
*/
toHexString(): string;
/**
* Get the timestamp and validate correctness.
*/
toString(): string;
}
/**
* A class representation of the BSON Binary type.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Binary.html
*/
export declare class Binary {
/**
* @param buffer A buffer object containing the binary data.
* @param subType The option binary type.
*/
constructor(buffer: Buffer, subType?: number);
/**
* Byte Array BSON type.
*/
static SUBTYPE_BYTE_ARRAY: number;
/**
* Default BSON type.
*/
static SUBTYPE_DEFAULT: number;
/**
* Function BSON type.
*/
static SUBTYPE_FUNCTION: number;
/**
* MD5 BSON type.
*/
static SUBTYPE_MD5: number;
/**
* User BSON type.
*/
static SUBTYPE_USER_DEFINED: number;
/**
* UUID BSON type.
*/
static SUBTYPE_UUID: number;
/**
* OLD UUID BSON type
*/
static SUBTYPE_UUID_OLD: number;
/**
* The length of the binary.
*/
length(): number;
/**
* Updates this binary with byte_value.
*
* @param byte_value A single byte we wish to write.
*/
put(byte_value: number | string): void;
/**
* Reads length bytes starting at position.
*
* @param position Read from the given position in the Binary.
* @param length The number of bytes to read.
*/
read(position: number, length: number): Buffer;
/**
* Returns the value of this binary as a string.
*/
value(): string;
/**
* Writes a buffer or string to the binary
*
* @param buffer A string or buffer to be written to the Binary BSON object.
* @param offset Specify the binary of where to write the content.
*/
write(buffer: Buffer | string, offset: number): void;
}
/**
* A class representation of the BSON Double type.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Double.html
*/
export declare class Double {
/**
* @param value The number we want to represent as a double.
*/
constructor(value: number);
/**
* Access the number value.
*/
valueOf(): number;
}
/**
* Long
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Long.html
*/
export declare class Long {
/**
* @param low The low (signed) 32 bits of the Long.
* @param high The high (signed) 32 bits of the Long.
*/
constructor(low: number, high: number);
static MAX_VALUE: Long;
static MIN_VALUE: Long;
static NEG_ONE: Long;
static ONE: Long;
static ZERO: Long;
/**
* Returns a Long representing the 64-bit integer that comes by concatenating the given high and low bits.
* Each is assumed to use 32 bits.
*
* @param lowBits The low 32-bits.
* @param highBits The high 32-bits.
*/
static fromBits(lowBits: number, highBits: number): Long;
/**
* Returns a Long representing the given (32-bit) integer value.
*
* @param value The 32-bit integer in question.
*/
static fromInt(value: number): Long;
/**
* Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
*
* @param value The number in question.
*/
static fromNumber(value: number): Long;
/**
* Returns a Long representation of the given string, written using the given radix.
*
* @param str The textual representation of the Long.
* @param radix The radix in which the text is written.
*/
static fromString(str: string, radix?: number): Long;
/**
* Returns the sum of this and the given Long.
*
* @param other Long to add to this one.
*/
add(other: Long): Long;
/**
* Returns the bitwise-AND of this Long and the given one.
*
* @param other The Long with which to AND.
*/
and(other: Long): Long;
/**
* Compares this Long with the given one.
*
* @param other Long to compare against.
*/
compare(other: Long): number;
/**
* Returns this Long divided by the given one.
*
* @param other Long by which to divide.
*/
div(other: Long): Long;
/**
* Return whether this Long equals the other.
*
* @param other Long to compare against.
*/
equals(other: Long): boolean;
/**
* Return the high 32-bits value.
*/
getHighBits(): number;
/**
* Return the low 32-bits value.
*/
getLowBits(): number;
/**
* Return the low unsigned 32-bits value.
*/
getLowBitsUnsigned(): number;
/**
* Returns the number of bits needed to represent the absolute value of this Long.
*/
getNumBitsAbs(): number;
/**
* Return whether this Long is greater than the other.
*
* @param other Long to compare against.
*/
greaterThan(other: Long): number;
/**
* Return whether this Long is greater than or equal to the other.
*
* @param other Long to compare against.
*/
greaterThanOrEqual(other: Long): number;
/**
* Return whether this value is negative.
*/
isNegative(): boolean;
/**
* Return whether this value is odd.
*/
isOdd(): boolean;
/**
* Return whether this value is zero.
*/
isZero(): boolean;
/**
* Return whether this Long is less than the other.
*
* @param other Long to compare against.
*/
lessThan(other: Long): boolean;
/**
* Return whether this Long is less than or equal to the other.
*
* @param other Long to compare against.
*/
lessThanOrEqual(other: Long): boolean;
/**
* Returns this Long modulo the given one.
*
* @param other Long by which to mod.
*/
modulo(other: Long): Long;
/**
* Returns the product of this and the given Long.
*
* @param other Long to multiply with this.
*/
multiply(other: Long): Long;
/**
* The negation of this value.
*/
negate(): Long;
/**
* The bitwise-NOT of this value.
*/
not(): Long;
/**
* Return whether this Long does not equal the other.
*
* @param other Long to compare against.
*/
notEquals(other: Long): boolean;
/**
* Returns the bitwise-OR of this Long and the given one.
*
* @param other The Long with which to OR.
*/
or(other: Long): Long;
/**
* Returns this Long with bits shifted to the left by the given amount.
*
* @param other The number of bits by which to shift.
*/
shiftLeft(other: number): Long;
/**
* Returns this Long with bits shifted to the right by the given amount.
*
* @param other The number of bits by which to shift.
*/
shiftRight(other: number): Long;
/**
* Returns this Long with bits shifted to the right by the given amount, with the new top bits matching the current sign bit.
*
* @param other The number of bits by which to shift.
*/
shiftRightUnsigned(other: number): Long;
/**
* Returns the difference of this and the given Long.
*
* @param other Long to subtract from this.
*/
subtract(other: Long): Long;
/**
* Return the int value.
*/
toInt(): number;
/**
* Return the JSON value.
*/
toJSON(): string;
/**
* Return the Number value.
*/
toNumber(): number;
/**
* Return the String value.
*
* @param opt_radix The radix in which the text should be written.
*/
toString(opt_radix?: number): string;
/**
* Returns the bitwise-XOR of this Long and the given one.
*
* @param other The Long with which to XOR.
*/
xor(other: Long): Long;
}
/**
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/MaxKey.html
*/
export declare class MaxKey {
}
/**
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/MinKey.html
*/
export declare class MinKey {
}
/**
* Timestamp.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Timestamp.html
*/
export declare class Timestamp {
/**
* @param low The low (signed) 32 bits of the Timestamp.
* @param high The high (signed) 32 bits of the Timestamp.
*/
constructor(low: number, high: number);
static MAX_VALUE: Timestamp;
static MIN_VALUE: Timestamp;
static NEG_ONE: Timestamp;
static ONE: Timestamp;
static ZERO: Timestamp;
/**
* Returns a Timestamp representing the 64-bit integer that comes by concatenating the
* given high and low bits. Each is assumed to use 32 bits..
*
* @param lowBits The low 32-bits.
* @param highBits The high 32-bits.
*/
static fromBits(lowBits: number, highBits: number): Timestamp;
/**
* Returns a Timestamp representing the given (32-bit) integer value.
*
* @param value The 32-bit integer in question.
*/
static fromInt(value: number): Timestamp;
/**
* Returns a Timestamp representing the given value, provided that it is a finite number. Otherwise, zero is returned.
*
* @param value The number in question.
*/
static fromNumber(value: number): Timestamp;
/**
* Returns a Timestamp representation of the given string, written using the given radix.
*
* @param str The textual representation of the Timestamp.
* @param radix The radix in which the text is written.
*/
static fromString(str: string, radix?: number): Timestamp;
/**
* Returns the sum of this and the given Timestamp.
*
* @param other Timestamp to add to this one.
*/
add(other: Timestamp): Timestamp;
/**
* Returns the bitwise-AND of this Timestamp and the given one.
*
* @param other Timestamp to add to this one.
*/
and(other: Timestamp): Timestamp;
/**
* Compares this Timestamp with the given one.
*
* @param other Timestamp to compare against.
*/
compare(other: Timestamp): number;
/**
* Returns this Timestamp divided by the given one.
*
* @param other Timestamp by which to divide.
*/
div(other: Timestamp): Timestamp;
/**
* Return whether this Timestamp equals the other
*
* @param other
*/
equals(other: Timestamp): boolean;
/**
* Return the high 32-bits value.
*/
getHighBits(): number;
/**
* Return the low 32-bits value.
*/
getLowBits(): number;
/**
* Return the low unsigned 32-bits value.
*/
getLowBitsUnsigned(): number;
/**
* Returns the number of bits needed to represent the absolute value of this Timestamp.
*/
getNumBitsAbs(): number;
/**
* Return whether this Timestamp is greater than the other.
*
* @param other Timestamp to compare against.
*/
greaterThan(other: Timestamp): number;
/**
* Return whether this Timestamp is greater than or equal to the other.
*
* @param other Timestamp to compare against.
*/
greaterThanOrEqual(other: Timestamp): number;
/**
* Return whether this value is negative.
*/
isNegative(): boolean;
/**
* IsOdd.
* Return whether this value is odd.
*/
isOdd(): boolean;
/**
* Return whether this value is zero.
*/
isZero(): boolean;
/**
* Return whether this Timestamp is less than the other.
*
* @param other Timestamp to compare against.
*/
lessThan(other: Timestamp): boolean;
/**
* Return whether this Timestamp is less than or equal to the other.
*
* @param other Timestamp to compare against.
*/
lessThanOrEqual(other: Timestamp): boolean;
/**
* Returns this Timestamp modulo the given one.
*
* @param other Timestamp by which to mod.
*/
modulo(other: Timestamp): Timestamp;
/**
* Returns the product of this and the given Timestamp.
*
* @param other Timestamp to multiply with this.
*/
multiply(other: Timestamp): Timestamp;
/**
* The negation of this value.
*/
negate(): Timestamp;
/**
* The bitwise-NOT of this value.
*/
not(): Timestamp;
/**
* Return whether this Timestamp does not equal the other.
*
* @param other Timestamp to compare against.
*/
notEquals(other: Timestamp): boolean;
/**
* Returns the bitwise-OR of this Timestamp and the given one.
*
* @param other The Timestamp with which to OR.
*/
or(other: Timestamp): Timestamp;
/**
* Returns this Timestamp with bits shifted to the left by the given amount.
*
* @param other The number of bits by which to shift.
*/
shiftLeft(other: number): Timestamp;
/**
* Returns this Timestamp with bits shifted to the right by the given amount.
*
* @param other The number of bits by which to shift.
*/
shiftRight(other: number): Timestamp;
/**
* Returns this Timestamp with bits shifted to the right by the given amount, with the new top bits matching the current sign bit.
*
* @param other
*/
shiftRightUnsigned(other: number): Timestamp;
/**
* Returns the difference of this and the given Timestamp.
*
* @param other Timestamp to subtract from this.
*/
subtract(other: Timestamp): Timestamp;
/**
* Return the int value.
*/
toInt(): number;
/**
* Return the JSON value.
*/
toJSON(): string;
/**
* Return the Number value.
*/
toNumber(): number;
/**
* Return the String value.
*
* @param radix The radix in which the text should be written.
*/
toString(radix?: number): string;
/**
* Returns the bitwise-XOR of this Timestamp and the given one.
*
* @param other The Timestamp with which to XOR.
*/
xor(other: Timestamp): Timestamp;
}
export interface CollectionDeleteOneOptions {
/**
* The write concern.
*/
w?: number | string;
/**
* The write concern timeout.
*/
wtimmeout?: number;
/**
* Specify a journal write concern.
*/
j?: boolean;
/**
* Allow driver to bypass schema validation in MongoDB 3.2 or higher.
*/
bypassDocumentValidation?: boolean;
}
export interface CollectionDistinctOptions {
/**
* The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED,
* ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
*/
readPreference?: ReadPreference | string;
}
/**
* Create a new ObjectID instance.
*
* @see 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;
/**
* Execute an aggregation framework pipeline against the collection, needs MongoDB >= 2.2
*
* @param pipeline Array containing all the aggregation framework commands for the execution.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate
*/
aggregate(pipeline: Object[], callback: MongoCallback): AggregationCursor;
/**
* Execute an aggregation framework pipeline against the collection, needs MongoDB >= 2.2
*
* @param pipeline Array containing all the aggregation framework commands for the execution.
* @param options Optional.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate
*/
aggregate(pipeline: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback): AggregationCursor;
/**
* Execute an aggregation framework pipeline against the collection, needs MongoDB >= 2.2
*
* @param pipeline Array containing all the aggregation framework commands for the execution.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate
*/
aggregate(pipeline: Object[], callback: MongoCallback): AggregationCursor;
/**
* Execute an aggregation framework pipeline against the collection, needs MongoDB >= 2.2
*
* @param pipeline Array containing all the aggregation framework commands for the execution.
* @param options Optional.
* @param callback Optional
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate
*/
aggregate(pipeline: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback): AggregationCursor;
/**
* BulkWrite.
*
* @param operations Bulk operations to perform.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite
*/
bulkWrite(operations: Object[], callback: MongoCallback): void;
/**
* BulkWrite.
*
* @param operations Bulk operations to perform.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite
*/
bulkWrite(operations: Object[], options?: CollectionBluckWriteOptions): Promise;
/**
* BulkWrite.
*
* @param operations Bulk operations to perform.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite
*/
bulkWrite(operations: Object[], options: CollectionBluckWriteOptions, callback: MongoCallback): void;
/**
* Count number of matching documents in the db to a query.
*
* @param query The query for the count.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#count
*/
count(query: Object, callback: MongoCallback): void;
/**
* Count number of matching documents in the db to a query.
*
* @param query The query for the count.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#count
*/
count(query: Object, options?: MongoCountPreferences): Promise;
/**
* Count number of matching documents in the db to a query.
*
* @param query The query for the count=
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#count
*/
count(query: Object, options: MongoCountPreferences, callback: MongoCallback): void;
/**
* Creates an index on the db and collection collection.
*
* @param fieldOrSpec Defines the index.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndex
*/
createIndex(fieldOrSpec: string | any, callback: MongoCallback): void;
/**
* Creates an index on the db and collection collection.
*
* @param fieldOrSpec Defines the index.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndex
*/
createIndex(fieldOrSpec: string | any, options?: MongodbIndexOptions): Promise;
/**
* Creates an index on the db and collection collection.
*
* @param fieldOrSpec Defines the index.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndex
*/
createIndex(fieldOrSpec: string | any, options: MongodbIndexOptions, callback: MongoCallback): void;
/**
* CreateIndexes.
*
* @param indexSpecs An array of index specifications to be created.
* @see 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.
*
* @param indexSpecs An array of index specifications to be created.
* @param callback The command result callback.
* @see 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[], callback: MongoCallback): void;
/**
* Delete multiple documents on MongoDB.
*
* @param filter The Filter used to select the documents to remove.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany
*/
deleteMany(filter: Object, callback: MongoCallback): void;
/**
* Delete multiple documents on MongoDB.
*
* @param filter The Filter used to select the documents to remove.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany
*/
deleteMany(filter: Object, options?: CollectionOptions): Promise;
/**
* Delete multiple documents on MongoDB.
*
* @param filter The Filter used to select the documents to remove.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany
*/
deleteMany(filter: Object, options: CollectionOptions, callback: MongoCallback): void;
/**
* Delete a document on MongoDB.
*
* @param filter The Filter used to select the document to remove.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteOne
*/
deleteOne(filter: Object, callback: MongoCallback): void;
/**
* Delete a document on MongoDB.
*
* @param filter The Filter used to select the document to remove.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteOne
*/
deleteOne(filter: Object, options?: CollectionDeleteOneOptions): Promise;
/**
* Delete a document on MongoDB.
*
* @param filter The Filter used to select the document to remove.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteOne
*/
deleteOne(filter: Object, options: CollectionDeleteOneOptions, callback: MongoCallback): void;
/**
* The distinct command returns returns a list of distinct values for the given key across a collection.
*
* @param key Field of the document to find distinct values for.
* @param query The query for filtering the set of documents to which we apply the distinct filter.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#distinct
*/
distinct(key: string, query: Object, callback: MongoCallback): void;
/**
* The distinct command returns returns a list of distinct values for the given key across a collection.
*
* @param key Field of the document to find distinct values for.
* @param query The query for filtering the set of documents to which we apply the distinct filter.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#distinct
*/
distinct(key: string, query: Object, options?: CollectionDistinctOptions): Promise;
/**
* The distinct command returns returns a list of distinct values for the given key across a collection.
*
* @param key Field of the document to find distinct values for.
* @param query The query for filtering the set of documents to which we apply the distinct filter.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#distinct
*/
distinct(key: string, query: Object, options: CollectionDistinctOptions, callback: MongoCallback): void;
/**
* Drop the collection from the database, removing it permanently. New accesses will create a new collection.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#drop
*/
drop(): Promise;
/**
* Drop the collection from the database, removing it permanently. New accesses will create a new collection.
*
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#drop
*/
drop(callback: MongoCallback): void;
/**
* Drops an index from this collection.
*
* @param indexName Name of the index to drop.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndex
*/
dropIndex(indexName: string, callback: MongoCallback): void;
/**
* Drops an index from this collection.
*
* @param indexName Name of the index to drop.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndex
*/
dropIndex(indexName: string, options?: CollectionOptions): Promise;
/**
* Drops an index from this collection.
*
* @param indexName Name of the index to drop.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndex
*/
dropIndex(indexName: string, options: CollectionOptions, callback: MongoCallback): void;
/**
* Drops all indexes from this collection.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndexes
*/
dropIndexes(): Promise;
/**
* Drops all indexes from this collection.
*
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndexes
*/
dropIndexes(callback?: MongoCallback): void;
/**
* Creates a cursor for a query that can be used to iterate over results from MongoDB.
*
* @param query The cursor query object.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#find
*/
find(query?: Object): Cursor;
/**
* Creates a cursor for a query that can be used to iterate over results from MongoDB.
*
* @param query The cursor query object.
* @see 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;
/**
* Fetches the first document that matches the query.
*
* @param query Query for find Operation.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne
* @deprecated use find().limit(1).next(function(err, doc){}).
*/
findOne(query: Object, callback: MongoCallback): void;
/**
* Fetches the first document that matches the query.
*
* @param query Query for find Operation.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne
* @deprecated use find().limit(1).next(function(err, doc){}).
*/
findOne(query: Object, options?: MongodbFindOneOptions): Promise;
/**
* Fetches the first document that matches the query.
*
* @param query Query for find Operation.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne
* @deprecated use find().limit(1).next(function(err, doc){}).
*/
findOne(query: Object, options: MongodbFindOneOptions, callback: MongoCallback): void;
/**
* Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.
*
* @param filter Document selection filter.
* @param callback The collection result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndDelete
*/
findOneAndDelete(filter: Object, callback: MongoCallback): void;
/**
* Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.
*
* @param filter Document selection filter.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndDelete
*/
findOneAndDelete(filter: Object, options?: FindOneAndDeleteOptions): Promise;
/**
* Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.
*
* @param filter Document selection filter.
* @param options Optional settings.
* @param callback The collection result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndDelete
*/
findOneAndDelete(filter: Object, options: FindOneAndDeleteOptions, callback: MongoCallback): void;
/**
* Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.
*
* @param filter Document selection filter.
* @param replacement Document replacing the matching document.
* @param callback The collection result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace
*/
findOneAndReplace(filter: Object, replacement: Object, callback: MongoCallback): void;
/**
* Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.
*
* @param filter Document selection filter.
* @param replacement Document replacing the matching document.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace
*/
findOneAndReplace(filter: Object, replacement: Object, options?: FindOneAndReplaceOption): Promise;
/**
* Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.
*
* @param filter Document selection filter.
* @param replacement Document replacing the matching document.
* @param options Optional settings.
* @param callback The collection result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace
*/
findOneAndReplace(filter: Object, replacement: Object, options: FindOneAndReplaceOption, callback: MongoCallback): void;
/**
* Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.
*
* @param filter Document selection filter.
* @param update Update operations to be performed on the document.
* @param callback The collection result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndUpdate
*/
findOneAndUpdate(filter: Object, update: Object, callback: MongoCallback): void;
/**
* Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.
*
* @param filter Document selection filter.
* @param update Update operations to be performed on the document.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndUpdate
*/
findOneAndUpdate(filter: Object, update: Object, options?: FindOneAndReplaceOption): Promise;
/**
* Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.
*
* @param filter Document selection filter.
* @param update Update operations to be performed on the document.
* @param options Optional settings.
* @param callback The collection result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndUpdate
*/
findOneAndUpdate(filter: Object, update: Object, options: FindOneAndReplaceOption, callback: MongoCallback): void;
/**
* Execute a geo search using a geo haystack index on a collection.
*
* @param x Point to search on the x axis, ensure the indexes are ordered in the same order.
* @param y Point to search on the y axis, ensure the indexes are ordered in the same order.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch
*/
geoHaystackSearch(x: number, y: number, callback: MongoCallback): void;
/**
* Execute a geo search using a geo haystack index on a collection.
*
* @param x Point to search on the x axis, ensure the indexes are ordered in the same order.
* @param y Point to search on the y axis, ensure the indexes are ordered in the same order.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch
*/
geoHaystackSearch(x: number, y: number, options?: GeoHaystackSearchOptions): Promise;
/**
* Execute a geo search using a geo haystack index on a collection.
*
* @param x Point to search on the x axis, ensure the indexes are ordered in the same order.
* @param y Point to search on the y axis, ensure the indexes are ordered in the same order.
* @param options Optional settings
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch
*/
geoHaystackSearch(x: number, y: number, options: GeoHaystackSearchOptions, callback: MongoCallback): void;
/**
* Execute the geoNear command to search for items in the collection.
*
* @param x Point to search on the x axis, ensure the indexes are ordered in the same order.
* @param y Point to search on the y axis, ensure the indexes are ordered in the same order.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoNear
*/
geoNear(x: number, y: number, callback: MongoCallback): void;
/**
* Execute the geoNear command to search for items in the collection.
*
* @param x Point to search on the x axis, ensure the indexes are ordered in the same order.
* @param y Point to search on the y axis, ensure the indexes are ordered in the same order.
* @param options Optionals.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoNear
*/
geoNear(x: number, y: number, options?: GeoNearOptions): Promise;
/**
* Execute the geoNear command to search for items in the collection.
*
* @param x Point to search on the x axis, ensure the indexes are ordered in the same order.
* @param y Point to search on the y axis, ensure the indexes are ordered in the same order.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoNear
*/
geoNear(x: number, y: number, options: GeoNearOptions, callback: MongoCallback): void;
/**
* Run a group command across a collection.
*
* @param keys An object, array or function expressing the keys to group by.
* @param condition An optional condition that must be true for a row to be considered.
* @param initial Initial value of the aggregation counter object.
* @param reduce The reduce function aggregates (reduces) the objects iterated.
* @param finalize An optional function to be run on each item in the result set just before the item is returned.
* @param command Specify if you wish to run using the internal group command or using eval, default is true.
* @param callback The command result callback.
* @see 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;
/**
* Run a group command across a collection.
*
* @param keys An object, array or function expressing the keys to group by.
* @param condition An optional condition that must be true for a row to be considered.
* @param initial Initial value of the aggregation counter object.
* @param reduce The reduce function aggregates (reduces) the objects iterated.
* @param finalize An optional function to be run on each item in the result set just before the item is returned.
* @param command Specify if you wish to run using the internal group command or using eval, default is true.
* @param options Optional.
* @see 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, options?: GroupOptions): Promise;
/**
* Run a group command across a collection.
*
* @param keys An object, array or function expressing the keys to group by.
* @param condition An optional condition that must be true for a row to be considered.
* @param initial Initial value of the aggregation counter object.
* @param reduce The reduce function aggregates (reduces) the objects iterated.
* @param finalize An optional function to be run on each item in the result set just before the item is returned.
* @param command Specify if you wish to run using the internal group command or using eval, default is true.
* @param options Optional settings.
* @param callback The command result callback.
* @see 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, options: GroupOptions, callback: MongoCallback): void;
/**
* Retrieve all the indexes on the collection.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexes
*/
indexes(): Promise;
/**
* Retrieve all the indexes on the collection.
*
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexes
*/
indexes(callback: MongoCallback): void;
/**
* Checks if one or more indexes exist on the collection, fails on first non-existing index.
*
* @param indexes One or more index names to check.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexExists
*/
indexExists(indexes: string | string[]): Promise;
/**
* Checks if one or more indexes exist on the collection, fails on first non-existing index.
*
* @param indexes One or more index names to check.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexExists
*/
indexExists(indexes: string | string[], callback: MongoCallback): void;
/**
* Retrieves this collections index info.
*
* @param callback The command result callback
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexInformation
*/
indexInformation(callback: MongoCallback): void;
/**
* Retrieves this collections index info.
*
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexInformation
*/
indexInformation(options?: {
full: boolean;
}): Promise;
/**
* Retrieves this collections index info.
*
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexInformation
*/
indexInformation(options: {
full: boolean;
}, callback: MongoCallback): void;
/**
* Initiate an In order bulk write operation, operations will be serially executed in the order they are added,
* creating a new operation for each switch in types.
*
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeOrderedBulkOp
*/
initializeOrderedBulkOp(options?: CollectionOptions): OrderedBulkOperation;
/**
* Initiate a Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order.
*
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeUnorderedBulkOp
*/
initializeUnorderedBulkOp(options?: CollectionOptions): UnorderedBulkOperation;
/** @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;
/**
* InsertMany.
*
* @param docs Documents to insert.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertMany
*/
insertMany(docs: Object[], callback: MongoCallback): void;
/**
* InsertMany.
*
* @param docs Documents to insert.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertMany
*/
insertMany(docs: Object[], options?: CollectionInsertManyOptions): Promise;
/**
* InsertMany.
*
* @param docs Documents to insert.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertMany
*/
insertMany(docs: Object[], options: CollectionInsertManyOptions, callback: MongoCallback): void;
/**
* InsertOne.
*
* @param docs Document to insert.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne
*/
insertOne(docs: Object, callback: MongoCallback): void;
/**
* InsertOne.
*
* @param docs Document to insert.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne
*/
insertOne(docs: Object, options?: CollectionInsertOneOptions): Promise;
/**
* InsertOne.
*
* @param docs Document to insert.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne
*/
insertOne(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void;
/**
* Returns if the collection is a capped collection.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#isCapped
*/
isCapped(): Promise;
/**
* Returns if the collection is a capped collection.
*
* @param callback The results callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#isCapped
*/
isCapped(callback: MongoCallback): void;
/**
* Get the list of all indexes information for the collection.
*
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#listIndexes
*/
listIndexes(options?: ListIndexesOptions): CommandCursor;
/**
* Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
*
* @param map The mapping function.
* @param reduce The reduce function.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#mapReduce
*/
mapReduce(map: Function | string, reduce: Function | string, callback: MongoCallback): void;
/**
* Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
*
* @param map The mapping function.
* @param reduce The reduce function.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#mapReduce
*/
mapReduce(map: Function | string, reduce: Function | string, options?: MapReduceOptions): Promise;
/**
* Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
*
* @param map The mapping function.
* @param reduce The reduce function.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#mapReduce
*/
mapReduce(map: Function | string, reduce: Function | string, options: MapReduceOptions, callback: MongoCallback): void;
/**
* Returns the options of the collection.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#options
*/
options(): Promise;
/**
* Returns the options of the collection.
*
* @param callback The results callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#options
*/
options(callback: MongoCallback): void;
/**
* Return N number of parallel cursors for a collection allowing parallel reading of entire collection. There are
* no ordering guarantees for returned results.
*
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#parallelCollectionScan
*/
parallelCollectionScan(callback: MongoCallback[]>): void;
/**
* Return N number of parallel cursors for a collection allowing parallel reading of entire collection. There are
* no ordering guarantees for returned results.
*
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#parallelCollectionScan
*/
parallelCollectionScan(options?: ParallelCollectionScanOptions): Promise[]>;
/**
* Return N number of parallel cursors for a collection allowing parallel reading of entire collection. There are
* no ordering guarantees for returned results.
*
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#parallelCollectionScan
*/
parallelCollectionScan(options: ParallelCollectionScanOptions, callback: MongoCallback[]>): void;
/**
* Reindex all indexes on the collection.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#reIndex
*/
reIndex(): Promise;
/**
* Reindex all indexes on the collection.
*
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#reIndex
*/
reIndex(callback: MongoCallback): void;
/** @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;
/**
* Rename the collection.
*
* @param newName New name of of the collection.
* @param callback The results callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#rename
*/
rename(newName: string, callback: MongoCallback): void;
/**
* Rename the collection.
*
* @param newName New name of of the collection.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#rename
*/
rename(newName: string, options?: {
dropTarget?: boolean;
}): Promise;
/**
* Rename the collection.
*
* @param newName New name of of the collection.
* @param options Optional settings.
* @param callback The results callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#rename
*/
rename(newName: string, options: {
dropTarget?: boolean;
}, callback: MongoCallback): void;
/**
* Replace a document on MongoDB.
*
* @param filter The Filter used to select the document to update.
* @param doc The Document that replaces the matching document.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#replaceOne
*/
replaceOne(filter: Object, doc: Object, callback: MongoCallback): void;
/**
* Replace a document on MongoDB.
*
* @param filter The Filter used to select the document to update.
* @param doc The Document that replaces the matching document.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#replaceOne
*/
replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise;
/**
* Replace a document on MongoDB.
*
* @param filter The Filter used to select the document to update.
* @param doc The Document that replaces the matching document.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#replaceOne
*/
replaceOne(filter: Object, doc: Object, options: ReplaceOneOptions, callback: MongoCallback): void;
/** @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;
/**
* Get all the collection statistics.
*
* @param callback The collection result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#stats
*/
stats(callback: MongoCallback): void;
/**
* Get all the collection statistics.
*
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#stats
*/
stats(options?: {
scale: number;
}): Promise;
/**
* Get all the collection statistics.
*
* @param options Optional settings.
* @param callback The collection result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#stats
*/
stats(options: {
scale: number;
}, callback: MongoCallback): void;
/** @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;
/**
* Update multiple documents on MongoDB.
*
* @param filter The Filter used to select the document to update.
* @param update The update operations to be applied to the document.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateMany
*/
updateMany(filter: Object, update: Object, callback: MongoCallback): void;
/**
* Update multiple documents on MongoDB.
*
* @param filter The Filter used to select the document to update.
* @param update The update operations to be applied to the document.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateMany
*/
updateMany(filter: Object, update: Object, options?: UpdateManyOptions): Promise;
/**
* Update multiple documents on MongoDB.
*
* @param filter The Filter used to select the document to update.
* @param update The update operations to be applied to the document.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateMany
*/
updateMany(filter: Object, update: Object, options: UpdateManyOptions, callback: MongoCallback): void;
/**
* Update a single document on MongoDB.
*
* @param filter The Filter used to select the document to update.
* @param update The update operations to be applied to the document.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateOne
*/
updateOne(filter: Object, update: Object, callback: MongoCallback): void;
/**
* Update a single document on MongoDB.
*
* @param filter The Filter used to select the document to update.
* @param update The update operations to be applied to the document.
* @param options Optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateOne
*/
updateOne(filter: Object, update: Object, options?: ReplaceOneOptions): Promise;
/**
* Update a single document on MongoDB.
*
* @param filter The Filter used to select the document to update.
* @param update The update operations to be applied to the document.
* @param options Optional settings.
* @param callback The command result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateOne
*/
updateOne(filter: Object, update: Object, options: ReplaceOneOptions, callback: MongoCallback): void;
}
/**
* The name of the target collection.
*
* @see http://docs.mongodb.org/manual/reference/command/collStats/
*/
export interface CollStats {
/**
* Namespace.
*/
ns: string;
/**
* The number of objects or documents in this collection.
*/
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;
/**
* A number that indicates the user-set flags on the collection. userFlags
* only appears when using the mmapv1 storage engine.
*/
userFlags: number;
/**
* Total index size in bytes.
*/
totalIndexSize: number;
/**
* Size of specific indexes in bytes.
*/
indexSizes: {
_id_: number;
username: number;
};
/**
* This field will be “true” if the collection is capped.
*/
capped: boolean;
/**
* Shows the maximum size of a capped collection.
*/
maxSize: boolean;
/**
* This document contains data reported directly by the WiredTiger engine and other data for internal diagnostic use.
*/
wiredTiger: any;
/**
* A document that reports data from the WiredTiger storage engine for each index in the collection.
* Other storage engines will return an empty document.
*/
indexDetails: any;
/**
*
*/
ok: number;
}
/**
* CollectionAggregationOptions.
*
* @see 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;
/**
* allowDiskUse lets the server know if it can use disk to store temporary results for the aggregation (requires mongodb 2.6 >).
*/
allowDiskUse?: boolean;
/**
* maxTimeMS specifies a cumulative time limit in milliseconds for processing operations on the cursor. MongoDB interrupts the operation at the earliest following interrupt point.
*/
maxTimeMS?: boolean;
/**
* Allow driver to bypass schema validation in MongoDB 3.2 or higher.
*/
bypassDocumentValidation?: boolean;
}
/**
* CollectionInsertManyOptions.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/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;
}
export interface UpdateManyOptions {
/**
* Update operation is an upsert.
*/
upsert?: boolean;
/**
* The write concern.
*/
w?: any;
/**
* The write concern timeout.
*/
wtimeout?: number;
/**
* Specify a journal write concern.
*/
j?: boolean;
}
/**
* CollectionBluckWriteOptions.
*
* @see 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;
}
/**
* BulkWriteOpResultObject.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~BulkWriteOpResult
*/
export interface BulkWriteOpResultObject {
/**
* Number of documents inserted.
*/
insertedCount?: number;
/**
* Number of documents matched for update.
*/
matchedCount?: number;
/**
* Number of documents modified.
*/
modifiedCount?: number;
/**
* Number of documents deleted.
*/
deletedCount?: number;
/**
* Number of documents upserted.
*/
upsertedCount?: number;
/**
* Inserted document generated Id's, hash key is the index of the originating operation.
*/
insertedIds?: any;
/**
* Upserted document generated Id's, hash key is the index of the originating operation.
*/
upsertedIds?: any;
/**
* The command result object.
*/
result?: any;
}
/**
* MongoCountPreferences.
*
* @see 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.PRIMARY, ReadPreference.PRIMARY_PREFERRED,
* ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
*/
readPreference?: ReadPreference | string;
}
/**
* DeleteWriteOpResultObject.
*
* @see 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.
* @param ok Is 1 if the command executed correctly.
* @param n The total count of documents deleted.
*/
result: {
ok?: number;
n?: number;
};
/**
* The connection object used for the operation.
*/
connection?: any;
/**
* The number of documents deleted.
*/
deletedCount?: number;
}
/**
* FindAndModifyWriteOpResultObject.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~findAndModifyWriteOpResult
*/
export interface FindAndModifyWriteOpResultObject {
/**
* Document returned from findAndModify command.
*/
value?: any;
/**
* The raw lastErrorObject returned from the command.
*/
lastErrorObject?: any;
/**
* Is 1 if the command executed correctly.
*/
ok?: number;
}
/**
* FindOneAndReplaceOption.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace
*/
export interface FindOneAndReplaceOption {
/**
* Limits the fields to return for all matching documents.
*/
projection?: Object;
/**
* Determines which document the operation modifies if the query selects multiple documents.
*/
sort?: Object;
/**
* The maximum amount of time to allow the query to run.
*/
maxTimeMS?: number;
/**
* Upsert the document if it does not exist.
*/
upsert?: boolean;
/**
* When false, returns the updated document rather than the original. The default is true.
*/
returnOriginal?: boolean;
}
/**
* GeoHaystackSearchOptions.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch
*/
export interface GeoHaystackSearchOptions {
/**
* The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED,
* ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
*/
readPreference?: ReadPreference | string;
/**
* Include results up to maxDistance from the point.
*/
maxDistance?: number;
/**
* Filter the results by a query.
*/
search?: Object;
/**
* Max number of results to return.
*/
limit?: number;
}
/**
* GeoNearOptions.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoNear
*/
export interface GeoNearOptions {
/**
* The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED,
* ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
*/
readPreference?: ReadPreference | string;
/**
* Max number of results to return.
*/
num?: number;
/**
* Include results starting at minDistance from a point (2.6 or higher).
*/
minDistance?: number;
/**
* Include results up to maxDistance from the point.
*/
maxDistance?: number;
/**
* Include a value to multiply the distances with allowing for range conversions.
*/
distanceMultiplier?: number;
/**
* Filter the results by a query.
*/
query?: Object;
/**
* Perform query using a spherical model.
*/
spherical?: boolean;
/**
* The closest location in a document to the center of the search region will always be returned MongoDB > 2.X.
*/
uniqueDocs?: boolean;
/**
* Include the location data fields in the top level of the results MongoDB > 2.X.
*/
includeLocs?: boolean;
}
/**
* A class representation of the BSON Code type.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/Code.html
*/
export declare class Code {
/**
*
* @param code a string or function.
* @param scope optional
*/
constructor(code: string | Function, scope?: Object);
/**
* A string or function.
*/
code: string | Function;
/**
* An optional scope for the function.
*/
scope: any;
}
/**
* CollectionOptions.
*
* @see 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;
}
/**
* Create a new OrderedBulkOperation instance (INTERNAL TYPE, do not instantiate directly).
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html
*/
export interface OrderedBulkOperation {
/**
* Get the number of operations in the bulk.
*/
length: number;
/**
* Execute the ordered bulk operation.
* @param callback The result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#execute
*/
execute(callback: MongoCallback): void;
/**
* Execute the ordered bulk operation.
* @param options optional.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#execute
*/
execute(options?: FSyncOptions): Promise;
/**
* Execute the ordered bulk operation.
* @param options Optional settings.
* @param callback The result callback.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#execute
*/
execute(options: FSyncOptions, callback: MongoCallback): void;
/**
* Initiate a find operation for an update/updateOne/remove/removeOne/replaceOne.
* @param selector The selector for the bulk operation.
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#find
*/
find(selector: Object): FindOperatorsOrdered;
/**
* Add a single insert document to the bulk operation.
* @param doc The document to insert
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#insert
*/
insert(doc: Object): OrderedBulkOperation;
}
/**
* BulkWriteResult.
*
* @see http://mongodb.github.io/node-mongodb-native/2.1/api/BulkWriteResult.html
*/
export interface BulkWriteResult {
/**
* Did bulk operation correctly execute.
*/
ok: number;
/**
* number of inserted documents.
*/
nInserted: number;
/**
* number of documents updated logically.
*/
nUpdated: number;
/**
* Number of upserted documents.
*/
nUpserted: number;
/**
*
Number of documents updated physically on disk.
*/
nModified: number;
/**
* Number of removed documents.
*/
nRemoved: number;
/**
* Return an array of inserted ids.
*/
getInsertedIds(): Array