Skip to content

Commit

Permalink
fix(types): allow $pull with _id
Browse files Browse the repository at this point in the history
Fix #12142
  • Loading branch information
vkarpov15 committed Aug 3, 2022
1 parent 25e4580 commit b57efec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions test/types/queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,16 @@ function gh12091() {
}
update.$addToSet.friendsNames = 'Jane Doe';
}

function gh12142() {
const schema = new Schema({ name: String, comments: [{ text: String }] });

const Test = model('Test', schema);

Test.updateOne(
{ _id: new Types.ObjectId() },
{
$pull: { comments: new Types.ObjectId() }
}
);
}
4 changes: 2 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ declare module 'mongoose' {
/** @see https://docs.mongodb.com/manual/reference/operator/update-array/ */
$addToSet?: Mutable<mongodb.SetFields<TSchema>>;
$pop?: AnyKeys<TSchema> & AnyObject;
$pull?: Mutable<mongodb.PullOperator<TSchema>>;
$push?: Mutable<mongodb.PushOperator<TSchema>>;
$pull?: AnyKeys<TSchema> & AnyObject;
$push?: AnyKeys<TSchema> & AnyObject;
$pullAll?: AnyKeys<TSchema> & AnyObject;

/** @see https://docs.mongodb.com/manual/reference/operator/update-bitwise/ */
Expand Down

0 comments on commit b57efec

Please sign in to comment.