Skip to content

Commit

Permalink
fix: bring back generics on find, do not pass to Filter
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Aug 12, 2021
1 parent 5fc0e60 commit 614ec7a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,18 @@ export class Collection<TSchema extends Document = Document> {
options: FindOptions,
callback: Callback<TSchema | undefined>
): void;

// allow an override of the schema.
findOne<T = TSchema>(): Promise<T | undefined>;
findOne<T = TSchema>(callback: Callback<T | undefined>): void;
findOne<T = TSchema>(filter: Filter<TSchema>): Promise<T | undefined>;
findOne<T = TSchema>(filter: Filter<TSchema>, options?: FindOptions): Promise<T | undefined>;
findOne<T = TSchema>(
filter: Filter<TSchema>,
options?: FindOptions,
callback?: Callback<T | undefined>
): void;

findOne(
filter?: Filter<TSchema> | Callback<TSchema | undefined>,
options?: FindOptions | Callback<TSchema | undefined>,
Expand Down Expand Up @@ -717,6 +729,7 @@ export class Collection<TSchema extends Document = Document> {
*/
find(): FindCursor<TSchema>;
find(filter: Filter<TSchema>, options?: FindOptions): FindCursor<TSchema>;
find<T>(filter: Filter<TSchema>, options?: FindOptions): FindCursor<T>;
find(filter?: Filter<TSchema>, options?: FindOptions): FindCursor<TSchema> {
if (arguments.length > 2) {
throw new MongoInvalidArgumentError(
Expand Down

0 comments on commit 614ec7a

Please sign in to comment.