Skip to content

Commit 38278e7

Browse files
Longboyysamualtnorman
authored andcommitted
MongoValue types broke
1 parent db1253f commit 38278e7

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

env.d.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -770,10 +770,12 @@ type Projection<Schema extends object> = Partial<{
770770

771771

772772
type MongoUpdateOperators<Schema extends object> = Partial<{
773+
/* Universal operators */
773774
$set: Partial<Record<string, MongoCommandValue> & Schema>
774775
$setOnInsert: Partial<Record<string, MongoCommandValue> & Schema>
775776
$unset: Partial<Record<string, ""> & Schema>
776777
$rename: Partial<Record<string, string> & Schema>
778+
/* Date & number operators */
777779
$inc: Partial<Record<string, number> & {
778780
[key in keyof Schema as Schema[key] extends number | Date ? key : never]: Schema[key] extends number ? number : Date
779781
}>
@@ -786,6 +788,7 @@ type MongoUpdateOperators<Schema extends object> = Partial<{
786788
$max: Partial<Record<string, number> & {
787789
[key in keyof Schema as Schema[key] extends number ? key : never]: number
788790
}>
791+
/* Array operators */
789792
$pop: Partial<Record<string, -1 | 1> & {
790793
[key in keyof Schema as Schema[key] extends Array<infer U> ? key : never]: -1 | 1
791794
}>
@@ -795,15 +798,14 @@ type MongoUpdateOperators<Schema extends object> = Partial<{
795798
$addToSet: Partial<Record<string, MongoCommandValue> & {
796799
[key in keyof Schema as Schema[key] extends Array<infer U> ? key : never]: Schema[key] | MongoUpdateArrayOperatorUniversalModifiers<Schema[key]>
797800
}>
801+
$pull: Partial<Record<string, MongoCommandValue> & {
802+
[key in keyof Schema as Schema[key] extends Array<infer U> ? key : never]: Schema[key] extends (infer U)[] ? U : Schema[key] | MongoQuerySelector<Schema[key]>
803+
}>
804+
$pullAll: Partial<Record<string, MongoCommandValue> & {
805+
[key in keyof Schema as Schema[key] extends Array<infer U> ? key : never]: Schema[key]
806+
}>
798807
}>
799808

800-
/*
801-
type MongoUpdateArrayOperators<T extends Array> = {
802-
$pop: -1 | 1,
803-
$pull: Query<T>,
804-
}
805-
*/
806-
807809
type MongoUpdateArrayOperatorUniversalModifiers<T> = Partial<{
808810
$each: T extends Array<infer U> ? T : T[]
809811
}>
@@ -957,7 +959,7 @@ declare const $db: {
957959
/** Find documents in a collection or view and returns a cursor to the selected documents.
958960
* @param query Specifies deletion criteria using query operators.
959961
* @param projection Specifies the fields to return in the documents that match the query filter. */
960-
f: <T extends object = object>(query?: Query<T>, projection?: Projection<T>) => Cursor<T>
962+
f: <T extends object = object>(query?: Query<T>, projection?: Projection<T>) => Cursor<MongoDocument<T>>
961963

962964
/** Update existing documents in a collection.
963965
* @param query Specifies deletion criteria using query operators.

0 commit comments

Comments
 (0)