Skip to content

Commit

Permalink
review comment cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
W-A-James committed Oct 1, 2024
1 parent 4ac8ff9 commit 61ddc6b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
10 changes: 8 additions & 2 deletions src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,18 @@ export class Collection<TSchema extends Document = Document> {
*/
async findOne(): Promise<WithId<TSchema> | null>;
async findOne(filter: Filter<TSchema>): Promise<WithId<TSchema> | null>;
async findOne(filter: Filter<TSchema>, options: FindOptions): Promise<WithId<TSchema> | null>;
async findOne(
filter: Filter<TSchema>,
options: Omit<FindOptions, 'timeoutMode'>
): Promise<WithId<TSchema> | null>;

// allow an override of the schema.
async findOne<T = TSchema>(): Promise<T | null>;
async findOne<T = TSchema>(filter: Filter<TSchema>): Promise<T | null>;
async findOne<T = TSchema>(filter: Filter<TSchema>, options?: FindOptions): Promise<T | null>;
async findOne<T = TSchema>(
filter: Filter<TSchema>,
options?: Omit<FindOptions, 'timeoutMode'>
): Promise<T | null>;

async findOne(
filter: Filter<TSchema> = {},
Expand Down
3 changes: 1 addition & 2 deletions src/gridfs/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,7 @@ function init(stream: GridFSBucketReadStream): void {
`Download timed out after ${stream.s.timeoutContext?.timeoutMS}ms`
);
} catch (error) {
if (!stream.destroyed)
stream.destroy(error);
if (!stream.destroyed) stream.destroy(error);
return;
}

Expand Down
5 changes: 3 additions & 2 deletions src/gridfs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { type Filter, TypedEventEmitter } from '../mongo_types';
import type { ReadPreference } from '../read_preference';
import type { Sort } from '../sort';
import { CSOTTimeoutContext } from '../timeout';
import { resolveOptions } from '../utils';
import { WriteConcern, type WriteConcernOptions } from '../write_concern';
import type { FindOptions } from './../operations/find';
import {
Expand Down Expand Up @@ -155,7 +156,7 @@ export class GridFSBucket extends TypedEventEmitter<GridFSBucketEvents> {
* @param id - The id of the file doc
*/
async delete(id: ObjectId, options?: { timeoutMS: number }): Promise<void> {
const timeoutMS = options?.timeoutMS ?? this.s.db.timeoutMS;
const { timeoutMS } = resolveOptions(this.s.db, options);
let timeoutContext: CSOTTimeoutContext | undefined = undefined;

if (timeoutMS) {
Expand Down Expand Up @@ -235,7 +236,7 @@ export class GridFSBucket extends TypedEventEmitter<GridFSBucketEvents> {

/** Removes this bucket's files collection, followed by its chunks collection. */
async drop(options?: { timeoutMS: number }): Promise<void> {
const timeoutMS = options?.timeoutMS ?? this.s.db.timeoutMS;
const { timeoutMS } = resolveOptions(this.s.db, options);
let timeoutContext: CSOTTimeoutContext | undefined = undefined;

if (timeoutMS) {
Expand Down
3 changes: 1 addition & 2 deletions src/gridfs/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ async function checkIndexes(stream: GridFSBucketWriteStream): Promise<void> {
{},
{
projection: { _id: 1 },
timeoutMS: remainingTimeMS,
timeoutMode: remainingTimeMS != null ? CursorTimeoutMode.LIFETIME : undefined
timeoutMS: remainingTimeMS
}
);
if (doc != null) {
Expand Down

0 comments on commit 61ddc6b

Please sign in to comment.