Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongoose type error #57

Closed
TudorIoanMarin opened this issue Feb 28, 2019 · 6 comments
Closed

Mongoose type error #57

TudorIoanMarin opened this issue Feb 28, 2019 · 6 comments

Comments

@TudorIoanMarin
Copy link

Hi,

I'm trying to run the library on a typescript project. I have [email protected] and @types/[email protected]. I am using the plugin as per the instructions. I also have:
interface ItemStructure extends Document {
...
}

const ItemSchema = new Schema({ ... })

ItemSchema.plugin(mongoose_delete, { overrideMethods: 'all' });

export const Item: Model = model(
'item',
ItemSchema
);

For some reason it appears that there is no delete function on type Model event after I extend the Item interface with said method. I am trying to replace some findByIdAndRemove query's with soft delete.

Error:
Property 'delete' does not exist on type 'Model<ItemStructure, {}>'

Additional info:
"os":"linux","arch":"x64"

Any help would be appreciated.

@htwibowo
Copy link

htwibowo commented Dec 14, 2019

+1, ESLint throwing errors when calling extended methods (findDeleted, findWithDeleted, etc.)

@adrianjarc
Copy link

adrianjarc commented Jun 8, 2020

To fix that typing issue install package @types/mongoose-delete (npm i -D @types/mongoose-delete) and than instead of using Model<ItemStructure, {}> use SoftDeleteModel<ItemStructure, {}>

@ajmas
Copy link
Contributor

ajmas commented Sep 9, 2020

@adrianjarc would it be worth adding something on this into the Read Me?

@adrianjarc
Copy link

@ajmas It would. But as I look at the state of this repository, I highly doubt it will get merged, even if I or anyone else makes this PR

@dsanel
Copy link
Owner

dsanel commented Aug 31, 2021

@adrianjarc @ajmas If you add some README instructions and create PR, I will be happy to check and merge it.

@dsanel dsanel closed this as completed Aug 31, 2021
ajmas added a commit to ajmas/mongoose-delete that referenced this issue Sep 20, 2021
@ajmas
Copy link
Contributor

ajmas commented Sep 20, 2021

I have created a PR with an example in Typescript. @adrianjarc if you have any suggestions on improving the example, please let me know.

dsanel added a commit that referenced this issue Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants