You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Mongoose version
7.0.3
Node.js version
18.15.0
MongoDB server version
6.0.5
Typescript version (if applicable)
5.0.2
Description
I'm trying to use .deleteOne method on the Document previously found with editor code suggestion.
Interesting thing is that it's not documented in https://mongoosejs.com/docs/api/document.html although it has the signature in document.d.ts.
/** Removes this document from the db. */
deleteOne(options?: QueryOptions): QueryWithHelpers<any, this, TQueryHelpers>;
I've tried to await this Query calling exec() on it as with Document.updateOne() or Model.deleteOne() but the error occured while method itself worked well deleting the document.
const team = await Team.findById(someId).exec();
await team.updateOne({title: 'My new title'}).exec(); // This works
await team.deleteOne().exec(); // team.deleteOne(...).exec is not a function
// await Team.deleteOne({_id: someId}).exec(); // This works
Of course for now i'll use Model method, there's no urgent problem, but the situation itself seemed suspicious to me, so I've reported it.
Steps to Reproduce
const teamSchema = new Schema({
title: {
type: String,
required: true
}
});
const Team = model('Team', teamSchema);
const team = await Team.create({title: 'Test'});
await team.deleteOne().exec();
Expected Behavior
Deleted document and awaitable Promise received without errors
The text was updated successfully, but these errors were encountered:
vkarpov15
added
typescript
Types or Types-test related issue / Pull Request
and removed
needs repro script
Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue
labels
May 2, 2023
Prerequisites
Mongoose version
7.0.3
Node.js version
18.15.0
MongoDB server version
6.0.5
Typescript version (if applicable)
5.0.2
Description
I'm trying to use .deleteOne method on the Document previously found with editor code suggestion.
Interesting thing is that it's not documented in https://mongoosejs.com/docs/api/document.html although it has the signature in document.d.ts.
I've tried to await this Query calling exec() on it as with Document.updateOne() or Model.deleteOne() but the error occured while method itself worked well deleting the document.
Of course for now i'll use Model method, there's no urgent problem, but the situation itself seemed suspicious to me, so I've reported it.
Steps to Reproduce
Expected Behavior
Deleted document and awaitable Promise received without errors
The text was updated successfully, but these errors were encountered: