From 6ea82ff17cac967602007d2a51cc14b7bea20911 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 23 Dec 2018 01:43:27 -0500 Subject: [PATCH] feat: export `Condition` Conditions can be used at the top level: ```typescript db.inventory.find( { $or: [ { quantity: { $lt: 20 } }, { price: 10 } ] } ) ``` Seems like the types in `@types/mongoose` marked the conditions as `any`, but exposing this `Condition` would provide for better typing in there as well. ```typescript findOne(conditions?: any, callback?: (err: any, res: T | null) => void): DocumentQuery & QueryHelpers; findOne(conditions: any, projection: any, callback?: (err: any, res: T | null) => void): DocumentQuery & QueryHelpers; findOne(conditions: any, projection: any, options: any, callback?: (err: any, res: T | null) => void): DocumentQuery & QueryHelpers; ``` --- types/mongodb/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index feb12923aa..15e21d2b43 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -999,7 +999,7 @@ export interface Collection { watch(pipeline?: Object[], options?: ChangeStreamOptions & { startAtClusterTime?: Timestamp, session?: ClientSession }): ChangeStream; } -type Condition = { +export type Condition = { $eq?: T[P]; $gt?: T[P]; $gte?: T[P];