Fixed generic type bug in Collection.find (#24857)

This commit is contained in:
Federico Caselli
2018-04-09 13:25:43 -07:00
committed by Mohamed Hegazy
parent 4e707e3844
commit 8070848da5
2 changed files with 4 additions and 2 deletions
+2 -2
View File
@@ -509,9 +509,9 @@ export interface Collection<TSchema = Default> {
dropIndexes(callback?: MongoCallback<any>): void;
dropIndexes(options: {session?: ClientSession, maxTimeMS?: number}, callback: MongoCallback<any>): void;
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#find */
find<T = TSchema>(query?: FilterQuery<T>): Cursor<T>;
find<T = TSchema>(query?: FilterQuery<TSchema>): Cursor<T>;
/** @deprecated */
find<T = TSchema>(query: FilterQuery<T>, options?: FindOneOptions): Cursor<T>;
find<T = TSchema>(query: FilterQuery<TSchema>, options?: FindOneOptions): Cursor<T>;
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#findOne */
findOne<T = TSchema>(filter: FilterQuery<TSchema>, callback: MongoCallback<T | null>): void;
findOne<T = TSchema>(filter: FilterQuery<TSchema>, options?: FindOneOptions): Promise<T | null>;
+2
View File
@@ -113,5 +113,7 @@ MongoClient.connect('mongodb://127.0.0.1:27017/test', options, function (err: mo
$and: [{ $gt: 0, $lt: 100 }]
}
});
const res: mongodb.Cursor<TestCollection> = testCollection.find({ _id: 123 });
}
})