Skip to content

Commit

Permalink
Filter: keep TSchema fields while changing $where root filter operator
Browse files Browse the repository at this point in the history
This is the only way I found to make sure to have TSchema fields type checked and autosuggestion available
  • Loading branch information
devmatteini committed Nov 11, 2024
1 parent bdd144b commit 225601b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/effect-mongodb/src/internal/filter.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import type { Filter as MongoFilter } from "mongodb"
import type { Condition, RootFilterOperators as MongoRootFilterOperators, WithId } from "mongodb"

export type Filter<T> = Omit<MongoFilter<T>, "$where"> & { $where?: string }
export type RootFilterOperators<TSchema> = Omit<MongoRootFilterOperators<TSchema>, "$where"> & { $where?: string }

export type Filter<TSchema> =
& {
[P in keyof WithId<TSchema>]?: Condition<WithId<TSchema>[P]>
}
& RootFilterOperators<WithId<TSchema>>

0 comments on commit 225601b

Please sign in to comment.