Skip to content

Commit

Permalink
fix(index.d.ts): allow specifying weights as an IndexOption
Browse files Browse the repository at this point in the history
Fix #10586
  • Loading branch information
vkarpov15 committed Aug 23, 2021
1 parent cb1e787 commit bf43078
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1748,7 +1748,8 @@ declare module 'mongoose' {
> = PopulatedType | RawId;

interface IndexOptions extends mongodb.IndexOptions {
expires?: number | string
expires?: number | string;
weights?: AnyObject;
}

interface ValidatorProps {
Expand Down
4 changes: 3 additions & 1 deletion test/typescript/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ const movieSchema = new Schema<Document<Movie>, Model<Document<Movie>>, Movie>({
});

movieSchema.index({ status: 1, 'actors.name': 1 });
movieSchema.index({ title: 'text' });
movieSchema.index({ title: 'text' }, {
weights: { title: 10 }
});
movieSchema.index({ rating: -1 });

// Using `SchemaDefinition`
Expand Down

0 comments on commit bf43078

Please sign in to comment.