Skip to content

Commit

Permalink
fix(index.d.ts): allow using $in and $nin on array paths
Browse files Browse the repository at this point in the history
Fix #10605
  • Loading branch information
vkarpov15 committed Sep 6, 2021
1 parent 5e59b01 commit 4d48869
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2458,11 +2458,11 @@ declare module 'mongoose' {
$eq?: T;
$gt?: T;
$gte?: T;
$in?: T[];
$in?: T extends AnyArray<any> ? Unpacked<T>[] : T[];
$lt?: T;
$lte?: T;
$ne?: T;
$nin?: T[];
$nin?: T extends AnyArray<any> ? Unpacked<T>[] : T[];
// Logical
$not?: T extends string ? QuerySelector<T> | RegExp : QuerySelector<T>;
// Element
Expand Down
1 change: 1 addition & 0 deletions test/typescript/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Test.find({ parent: '0'.repeat(24) });
// Operators
Test.find({ name: { $in: ['Test'] } }).exec().then((res: Array<ITest>) => console.log(res));
Test.find({ tags: 'test' }).exec();
Test.find({ tags: { $in: ['test'] } }).exec();

Test.find({ name: 'test' }, (err: Error, docs: ITest[]) => {
console.log(!!err, docs[0].age);
Expand Down

0 comments on commit 4d48869

Please sign in to comment.