Skip to content

Commit 614ec7a

Browse files
committed
fix: bring back generics on find, do not pass to Filter
1 parent 5fc0e60 commit 614ec7a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/collection.ts

+13
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,18 @@ export class Collection<TSchema extends Document = Document> {
682682
options: FindOptions,
683683
callback: Callback<TSchema | undefined>
684684
): void;
685+
686+
// allow an override of the schema.
687+
findOne<T = TSchema>(): Promise<T | undefined>;
688+
findOne<T = TSchema>(callback: Callback<T | undefined>): void;
689+
findOne<T = TSchema>(filter: Filter<TSchema>): Promise<T | undefined>;
690+
findOne<T = TSchema>(filter: Filter<TSchema>, options?: FindOptions): Promise<T | undefined>;
691+
findOne<T = TSchema>(
692+
filter: Filter<TSchema>,
693+
options?: FindOptions,
694+
callback?: Callback<T | undefined>
695+
): void;
696+
685697
findOne(
686698
filter?: Filter<TSchema> | Callback<TSchema | undefined>,
687699
options?: FindOptions | Callback<TSchema | undefined>,
@@ -717,6 +729,7 @@ export class Collection<TSchema extends Document = Document> {
717729
*/
718730
find(): FindCursor<TSchema>;
719731
find(filter: Filter<TSchema>, options?: FindOptions): FindCursor<TSchema>;
732+
find<T>(filter: Filter<TSchema>, options?: FindOptions): FindCursor<T>;
720733
find(filter?: Filter<TSchema>, options?: FindOptions): FindCursor<TSchema> {
721734
if (arguments.length > 2) {
722735
throw new MongoInvalidArgumentError(

0 commit comments

Comments
 (0)