[@types/mongoose] Add missing options?: mongodb.CollectionBulkWriteOptions to Model.bulkWrite (#38059)

* Update index.d.ts

* Update mongoose-tests.ts

* Update mongoose-tests.ts
This commit is contained in:
Anton Kenikh
2019-09-03 17:03:51 -07:00
committed by Ron Buckton
parent 3a47df29de
commit c823c6e10e
2 changed files with 9 additions and 2 deletions
+4
View File
@@ -29,6 +29,7 @@
// Brian Chen <https://github.com/ToucheSir>
// Boris Figovsky <https://github.com/borfig>
// Simon Driscoll <https://github.com/dinodeSimon>
// Anton Kenikh <https://github.com/anthony-kenikh>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -2876,10 +2877,13 @@ declare module "mongoose" {
* Mongoose will perform casting on all operations you provide.
* This function does not trigger any middleware, not save() nor update(). If you need to trigger save() middleware for every document use create() instead.
* @param writes Operations
* @param options Optional settings. See https://mongoosejs.com/docs/api/model.html#model_Model.bulkWrite
* @param cb callback
* @return `BulkWriteOpResult` if the operation succeeds
*/
bulkWrite(writes: any[], cb?: (err: any, res: mongodb.BulkWriteOpResultObject) => void): Promise<mongodb.BulkWriteOpResultObject>;
bulkWrite(writes: any[], options?: mongodb.CollectionBulkWriteOptions): Promise<mongodb.BulkWriteOpResultObject>;
bulkWrite(writes: any[], options: mongodb.CollectionBulkWriteOptions, cb: (err: any, res: mongodb.BulkWriteOpResultObject) => void): void;
/**
* Finds a single document by its _id field. findById(id) is almost*
+5 -2
View File
@@ -778,8 +778,11 @@ MyModel.bulkWrite([{foo:'bar'}]).then(r => {
console.log(r.deletedCount);
});
MyModel.bulkWrite([], (err, res) => {
console.log(res.modifiedCount)
})
console.log(res.modifiedCount);
});
MyModel.bulkWrite([], { ordered: false }, (err, res) => {
console.log(res.modifiedCount);
});
doc.populate('path');
doc.populate({path: 'hello'});
doc.populate('path', cb)