@@ -127,6 +127,14 @@ declare module "mongodb" {
127127 // Creates an ObjectID from a hex string representation of an ObjectID.
128128 // hexString – create a ObjectID from a passed in 24 byte hexstring.
129129 public static createFromHexString ( hexString : string ) : ObjectID ;
130+
131+ // Checks if a value is a valid bson ObjectId
132+ // id - Value to be checked
133+ public static isValid ( id : string ) : Boolean ;
134+
135+ // Generate a 12 byte id string used in ObjectID's
136+ // time - optional parameter allowing to pass in a second based timestamp
137+ public generate ( time ?: number ) : string ;
130138 }
131139
132140 // Class documentation : http://mongodb.github.io/node-mongodb-native/api-bson-generated/binary.html
@@ -253,24 +261,97 @@ declare module "mongodb" {
253261 pkFactory ?: PKFactory ;
254262 }
255263
264+ // Documentation: http://docs.mongodb.org/manual/reference/command/collStats/
265+ export interface CollStats {
266+ // Namespace.
267+ ns : string ;
268+
269+ // Number of documents.
270+ count : number ;
271+
272+ // Collection size in bytes.
273+ size : number ;
274+
275+ // Average object size in bytes.
276+ avgObjSize : number ;
277+
278+ // (Pre)allocated space for the collection in bytes.
279+ storageSize : number ;
280+
281+ // Number of extents (contiguously allocated chunks of datafile space).
282+ numExtents : number ;
283+
284+ // Number of indexes.
285+ nindexes : number ;
286+
287+ // Size of the most recently created extent in bytes.
288+ lastExtentSize : number ;
289+
290+ // Padding can speed up updates if documents grow.
291+ paddingFactor : number ;
292+ flags : number ;
293+
294+ // Total index size in bytes.
295+ totalIndexSize : number ;
296+
297+ // Size of specific indexes in bytes.
298+ indexSizes : {
299+ _id_ : number ;
300+ username : number ;
301+ } ;
302+ }
303+
256304 // Documentation : http://mongodb.github.io/node-mongodb-native/api-generated/collection.html
257305 export interface Collection {
258306 new ( db : Db , collectionName : string , pkFactory ?: Object , options ?: CollectionCreateOptions ) : Collection ; // is this right?
259-
307+ /**
308+ * @deprecated use insertOne or insertMany
309+ * Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#insert
310+ */
260311 insert ( query : any , callback : ( err : Error , result : any ) => void ) : void ;
261312 insert ( query : any , options : { safe ?: any ; continueOnError ?: boolean ; keepGoing ?: boolean ; serializeFunctions ?: boolean ; } , callback : ( err : Error , result : any ) => void ) : void ;
262313
314+ // Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#insertOne
315+ insertOne ( doc :any , callback : ( err : Error , result : any ) => void ) :void ;
316+ insertOne ( doc : any , options : { w ?: any ; wtimeout ?: number ; j ?: boolean ; serializeFunctions ?: boolean ; forceServerObjectId ?: boolean } , callback : ( err : Error , result : any ) => void ) : void ;
317+
318+ // Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#insertMany
319+ insertMany ( docs : any , callback : ( err : Error , result : any ) => void ) : void ;
320+ insertMany ( docs : any , options : { w ?: any ; wtimeout ?: number ; j ?: boolean ; serializeFunctions ?: boolean ; forceServerObjectId ?: boolean } , callback : ( err : Error , result : any ) => void ) : void ;
321+ /**
322+ * @deprecated use deleteOne or deleteMany
323+ * Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#remove
324+ */
263325 remove ( selector : Object , callback ?: ( err : Error , result : any ) => void ) : void ;
264326 remove ( selector : Object , options : { safe ?: any ; single ?: boolean ; } , callback ?: ( err : Error , result : any ) => void ) : void ;
265327
328+ // Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#deleteOne
329+ deleteOne ( filter : any , callback : ( err : Error , result : any ) => void ) : void ;
330+ deleteOne ( filter : any , options : { w ?: any ; wtimeout ?: number ; j ?: boolean ; } , callback : ( err : Error , result : any ) => void ) : void ;
331+
332+ // Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#deleteMany
333+ deleteMany ( filter : any , callback : ( err : Error , result : any ) => void ) : void ;
334+ deleteMany ( filter : any , options : { w ?: any ; wtimeout ?: number ; j ?: boolean ; } , callback : ( err : Error , result : any ) => void ) : void ;
335+
266336 rename ( newName : String , callback ?: ( err : Error , result : any ) => void ) : void ;
267337
268338 save ( doc : any , callback : ( err : Error , result : any ) => void ) : void ;
269- save ( doc : any , options : { safe : any ; } , callback : ( err : Error , result : any ) => void ) : void ;
270-
339+ save ( doc : any , options : { w ?: any ; wtimeout ?: number ; j ?: boolean ; } , callback : ( err : Error , result : any ) => void ) : void ;
340+ /**
341+ * @deprecated use updateOne or updateMany
342+ * Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#update
343+ */
271344 update ( selector : Object , document : any , callback ?: ( err : Error , result : any ) => void ) : void ;
272345 update ( selector : Object , document : any , options : { safe ?: boolean ; upsert ?: any ; multi ?: boolean ; serializeFunctions ?: boolean ; } , callback : ( err : Error , result : any ) => void ) : void ;
273346
347+ // Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#updateOne
348+ updateOne ( filter : Object , update : any , callback : ( err : Error , result : any ) => void ) : void ;
349+ updateOne ( filter : Object , update : any , options : { upsert ?: boolean ; w ?: any ; wtimeout ?: number ; j ?: boolean ; } , callback : ( err : Error , result : any ) => void ) : void ;
350+
351+ // Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#updateMany
352+ updateMany ( filter : Object , update : any , callback : ( err : Error , result : any ) => void ) : void ;
353+ updateMany ( filter : Object , update : any , options : { upsert ?: boolean ; w ?: any ; wtimeout ?: number ; j ?: boolean ; } , callback : ( err : Error , result : any ) => void ) : void ;
354+
274355 distinct ( key : string , query : Object , callback : ( err : Error , result : any ) => void ) : void ;
275356 distinct ( key : string , query : Object , options : { readPreference : string ; } , callback : ( err : Error , result : any ) => void ) : void ;
276357
@@ -279,13 +360,31 @@ declare module "mongodb" {
279360 count ( query : Object , options : { readPreference : string ; } , callback : ( err : Error , result : any ) => void ) : void ;
280361
281362 drop ( callback ?: ( err : Error , result : any ) => void ) : void ;
282-
363+ /**
364+ * @deprecated use findOneAndUpdate, findOneAndReplace or findOneAndDelete
365+ * Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify
366+ */
283367 findAndModify ( query : Object , sort : any [ ] , doc : Object , callback : ( err : Error , result : any ) => void ) : void ;
284368 findAndModify ( query : Object , sort : any [ ] , doc : Object , options : { safe ?: any ; remove ?: boolean ; upsert ?: boolean ; new ?: boolean ; } , callback : ( err : Error , result : any ) => void ) : void ;
285-
369+ /**
370+ * @deprecated use findOneAndDelete
371+ * Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndRemove
372+ */
286373 findAndRemove ( query : Object , sort ? : any [ ] , callback ?: ( err : Error , result : any ) => void ) : void ;
287374 findAndRemove ( query : Object , sort ? : any [ ] , options ?: { safe : any ; } , callback ?: ( err : Error , result : any ) => void ) : void ;
288375
376+ // Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findOneAndDelete
377+ findOneAndDelete ( filter : any , callback : ( err : Error , result : any ) => void ) : void ;
378+ findOneAndDelete ( filter : any , options : { projection ?: any ; sort ?: any ; maxTimeMS ?: number ; } , callback : ( err : Error , result : any ) => void ) : void ;
379+
380+ // Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findOneAndReplace
381+ findOneAndReplace ( filter : any , replacement : any , callback : ( err : Error , result : any ) => void ) : void ;
382+ findOneAndReplace ( filter : any , replacement : any , options : { projection ?: any ; sort ?: any ; maxTimeMS ?: number ; upsert ?: boolean ; returnOriginal ?: boolean } , callback : ( err : Error , result : any ) => void ) : void ;
383+
384+ // Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findOneAndUpdate
385+ findOneAndUpdate ( filter : any , update : any , callback : ( err : Error , result : any ) => void ) : void ;
386+ findOneAndUpdate ( filter : any , update : any , options : { projection ?: any ; sort ?: any ; maxTimeMS ?: number ; upsert ?: boolean ; returnOriginal ?: boolean } , callback : ( err : Error , result : any ) => void ) : void ;
387+
289388 find ( callback ?: ( err : Error , result : Cursor ) => void ) : Cursor ;
290389 find ( selector : Object , callback ?: ( err : Error , result : Cursor ) => void ) : Cursor ;
291390 find ( selector : Object , fields : any , callback ?: ( err : Error , result : Cursor ) => void ) : Cursor ;
@@ -326,8 +425,8 @@ declare module "mongodb" {
326425 indexes ( callback : Function ) : void ;
327426 aggregate ( pipeline : any [ ] , callback : ( err : Error , results : any ) => void ) : void ;
328427 aggregate ( pipeline : any [ ] , options : { readPreference : string } , callback : ( err : Error , results : any ) => void ) : void ;
329- stats ( options : { readPreference : string ; scale : number } , callback : Function ) : void ;
330- stats ( callback : ( err : Error , results : any ) => void ) : void ;
428+ stats ( options : { readPreference : string ; scale : number } , callback : ( err : Error , results : CollStats ) => void ) : void ;
429+ stats ( callback : ( err : Error , results : CollStats ) => void ) : void ;
331430
332431 hint : any ;
333432 }
@@ -436,6 +535,7 @@ declare module "mongodb" {
436535 export interface MongoCollectionOptions {
437536 safe ?: any ;
438537 serializeFunctions ?: any ;
538+ strict ?: boolean ;
439539 raw ?: boolean ;
440540 pkFactory ?: any ;
441541 readPreference ?: string ;
0 commit comments