@@ -127,6 +127,14 @@ declare module "mongodb" {
127
127
// Creates an ObjectID from a hex string representation of an ObjectID.
128
128
// hexString – create a ObjectID from a passed in 24 byte hexstring.
129
129
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 ;
130
138
}
131
139
132
140
// Class documentation : http://mongodb.github.io/node-mongodb-native/api-bson-generated/binary.html
@@ -253,24 +261,97 @@ declare module "mongodb" {
253
261
pkFactory ?: PKFactory ;
254
262
}
255
263
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
+
256
304
// Documentation : http://mongodb.github.io/node-mongodb-native/api-generated/collection.html
257
305
export interface Collection {
258
306
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
+ */
260
311
insert ( query : any , callback : ( err : Error , result : any ) => void ) : void ;
261
312
insert ( query : any , options : { safe ?: any ; continueOnError ?: boolean ; keepGoing ?: boolean ; serializeFunctions ?: boolean ; } , callback : ( err : Error , result : any ) => void ) : void ;
262
313
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
+ */
263
325
remove ( selector : Object , callback ?: ( err : Error , result : any ) => void ) : void ;
264
326
remove ( selector : Object , options : { safe ?: any ; single ?: boolean ; } , callback ?: ( err : Error , result : any ) => void ) : void ;
265
327
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
+
266
336
rename ( newName : String , callback ?: ( err : Error , result : any ) => void ) : void ;
267
337
268
338
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
+ */
271
344
update ( selector : Object , document : any , callback ?: ( err : Error , result : any ) => void ) : void ;
272
345
update ( selector : Object , document : any , options : { safe ?: boolean ; upsert ?: any ; multi ?: boolean ; serializeFunctions ?: boolean ; } , callback : ( err : Error , result : any ) => void ) : void ;
273
346
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
+
274
355
distinct ( key : string , query : Object , callback : ( err : Error , result : any ) => void ) : void ;
275
356
distinct ( key : string , query : Object , options : { readPreference : string ; } , callback : ( err : Error , result : any ) => void ) : void ;
276
357
@@ -279,13 +360,31 @@ declare module "mongodb" {
279
360
count ( query : Object , options : { readPreference : string ; } , callback : ( err : Error , result : any ) => void ) : void ;
280
361
281
362
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
+ */
283
367
findAndModify ( query : Object , sort : any [ ] , doc : Object , callback : ( err : Error , result : any ) => void ) : void ;
284
368
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
+ */
286
373
findAndRemove ( query : Object , sort ? : any [ ] , callback ?: ( err : Error , result : any ) => void ) : void ;
287
374
findAndRemove ( query : Object , sort ? : any [ ] , options ?: { safe : any ; } , callback ?: ( err : Error , result : any ) => void ) : void ;
288
375
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
+
289
388
find ( callback ?: ( err : Error , result : Cursor ) => void ) : Cursor ;
290
389
find ( selector : Object , callback ?: ( err : Error , result : Cursor ) => void ) : Cursor ;
291
390
find ( selector : Object , fields : any , callback ?: ( err : Error , result : Cursor ) => void ) : Cursor ;
@@ -326,8 +425,8 @@ declare module "mongodb" {
326
425
indexes ( callback : Function ) : void ;
327
426
aggregate ( pipeline : any [ ] , callback : ( err : Error , results : any ) => void ) : void ;
328
427
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 ;
331
430
332
431
hint : any ;
333
432
}
@@ -436,6 +535,7 @@ declare module "mongodb" {
436
535
export interface MongoCollectionOptions {
437
536
safe ?: any ;
438
537
serializeFunctions ?: any ;
538
+ strict ?: boolean ;
439
539
raw ?: boolean ;
440
540
pkFactory ?: any ;
441
541
readPreference ?: string ;
0 commit comments