From 42379c6e5f5185f18ac27ad2fc50d645cffbe99b Mon Sep 17 00:00:00 2001 From: Eliott C Date: Sat, 4 Jun 2022 02:06:50 +0200 Subject: [PATCH 1/3] fix(types): Allow sorting by text score Sorting by text score is a special case. See https://www.mongodb.com/docs/manual/reference/method/cursor.sort/#text-score-metadata-sort This fixes a type error caused by 6.3.5 --- types/query.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/query.d.ts b/types/query.d.ts index ab7174f11b0..ac455a25cbb 100644 --- a/types/query.d.ts +++ b/types/query.d.ts @@ -579,7 +579,7 @@ declare module 'mongoose' { snapshot(val?: boolean): this; /** Sets the sort order. If an object is passed, values allowed are `asc`, `desc`, `ascending`, `descending`, `1`, and `-1`. */ - sort(arg?: string | { [key: string]: SortOrder } | undefined | null): this; + sort(arg?: string | { [key: string]: SortOrder } | { score: { $meta: 'textScore' } } | undefined | null): this; /** Sets the tailable option (for use with capped collections). */ tailable(bool?: boolean, opts?: { From 72708ca4dac1e5188e597084fb8a55ca99c58a28 Mon Sep 17 00:00:00 2001 From: Eliott C Date: Sun, 5 Jun 2022 17:56:52 +0200 Subject: [PATCH 2/3] Update query.d.ts --- types/query.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/query.d.ts b/types/query.d.ts index ac455a25cbb..4f8e9b400c8 100644 --- a/types/query.d.ts +++ b/types/query.d.ts @@ -579,7 +579,7 @@ declare module 'mongoose' { snapshot(val?: boolean): this; /** Sets the sort order. If an object is passed, values allowed are `asc`, `desc`, `ascending`, `descending`, `1`, and `-1`. */ - sort(arg?: string | { [key: string]: SortOrder } | { score: { $meta: 'textScore' } } | undefined | null): this; + sort(arg?: string | { [key: string]: SortOrder } | { [key: string]: { $meta: 'textScore' } } | undefined | null): this; /** Sets the tailable option (for use with capped collections). */ tailable(bool?: boolean, opts?: { From 38c4f13b5d77cd94262a88c7164887062219feb2 Mon Sep 17 00:00:00 2001 From: Eliott C Date: Sun, 5 Jun 2022 17:58:00 +0200 Subject: [PATCH 3/3] Update query.d.ts --- types/query.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/query.d.ts b/types/query.d.ts index 4f8e9b400c8..541974e6f75 100644 --- a/types/query.d.ts +++ b/types/query.d.ts @@ -579,7 +579,7 @@ declare module 'mongoose' { snapshot(val?: boolean): this; /** Sets the sort order. If an object is passed, values allowed are `asc`, `desc`, `ascending`, `descending`, `1`, and `-1`. */ - sort(arg?: string | { [key: string]: SortOrder } | { [key: string]: { $meta: 'textScore' } } | undefined | null): this; + sort(arg?: string | { [key: string]: SortOrder | { $meta: 'textScore' } } | undefined | null): this; /** Sets the tailable option (for use with capped collections). */ tailable(bool?: boolean, opts?: {