From 6adf912c3844c7f735cb6b6cfb479d8b28636059 Mon Sep 17 00:00:00 2001 From: Alan Marcell Date: Sun, 25 Jun 2017 18:32:48 -0300 Subject: [PATCH 1/2] Add mongodb Collection.replaceOne(...) return type WriteOpResult In case of Collection.replaceOne(..., {upsert:true}) the return type is an WriteOpResult --- types/mongodb/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index 18e627ebfc..aee64a729c 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for MongoDB v2.2 // Project: https://github.com/mongodb/node-mongodb-native/tree/2.2 // Definitions by: Federico Caselli +// Alan Marcell // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -585,9 +586,9 @@ export interface Collection { rename(newName: string, callback: MongoCallback>): void; rename(newName: string, options?: { dropTarget?: boolean }): Promise>; rename(newName: string, options: { dropTarget?: boolean }, callback: MongoCallback>): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#replaceOne + //http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#replaceOne replaceOne(filter: Object, doc: Object, callback: MongoCallback): void; - replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise; + replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise | Promise; replaceOne(filter: Object, doc: Object, options: ReplaceOneOptions, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#save /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ From a060f7558c73fc90139973f077b928923d4ad341 Mon Sep 17 00:00:00 2001 From: Alan Marcell Date: Tue, 27 Jun 2017 16:44:32 -0300 Subject: [PATCH 2/2] Change replaceOne to Promise }> --- types/mongodb/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index aee64a729c..311e696c8a 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -587,9 +587,9 @@ export interface Collection { rename(newName: string, options?: { dropTarget?: boolean }): Promise>; rename(newName: string, options: { dropTarget?: boolean }, callback: MongoCallback>): void; //http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#replaceOne - replaceOne(filter: Object, doc: Object, callback: MongoCallback): void; - replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise | Promise; - replaceOne(filter: Object, doc: Object, options: ReplaceOneOptions, callback: MongoCallback): void; + replaceOne(filter: Object, doc: Object, callback: MongoCallback }>): void; + replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise }>; + replaceOne(filter: Object, doc: Object, options: ReplaceOneOptions, callback: MongoCallback }>): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#save /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ save(doc: Object, callback: MongoCallback): void;