Skip to content

Commit bf43078

Browse files
committedAug 23, 2021
fix(index.d.ts): allow specifying weights as an IndexOption
Fix #10586
1 parent cb1e787 commit bf43078

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
 

‎index.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,8 @@ declare module 'mongoose' {
17481748
> = PopulatedType | RawId;
17491749

17501750
interface IndexOptions extends mongodb.IndexOptions {
1751-
expires?: number | string
1751+
expires?: number | string;
1752+
weights?: AnyObject;
17521753
}
17531754

17541755
interface ValidatorProps {

‎test/typescript/schema.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ const movieSchema = new Schema<Document<Movie>, Model<Document<Movie>>, Movie>({
6767
});
6868

6969
movieSchema.index({ status: 1, 'actors.name': 1 });
70-
movieSchema.index({ title: 'text' });
70+
movieSchema.index({ title: 'text' }, {
71+
weights: { title: 10 }
72+
});
7173
movieSchema.index({ rating: -1 });
7274

7375
// Using `SchemaDefinition`

0 commit comments

Comments
 (0)
Please sign in to comment.