Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions test/types/queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,3 +672,9 @@ async function gh14545() {
const myProjection = await M.findOne({}).select<SlimTest>({ prop: 1 }).exec();
expectType<SlimTestDocument | null>(myProjection);
}

function gh14841() {
const filter: FilterQuery<{ owners: string[] }> = {
$expr: { $lt: [{ $size: '$owners' }, 10] }
};
}
1 change: 1 addition & 0 deletions types/query.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ declare module 'mongoose' {
$where?: string | Function;
/** @see https://www.mongodb.com/docs/manual/reference/operator/query/comment/#op._S_comment */
$comment?: string;
$expr?: Record<string, any>;
// we could not find a proper TypeScript generic to support nested queries e.g. 'user.friends.name'
// this will mark all unrecognized properties as any (including nested queries) only if
// they include a "." (to avoid generically allowing any unexpected keys)
Expand Down