Comments (6)
Definitely something worth introducing. Thanks for the suggestion.
from mongoose-softdelete.
I released a new version of this plugin v1.1.0 that adds types. Please try it out and let me know if it works for your use case. Cheers!
from mongoose-softdelete.
Hi,
I do have some problems here, I put them here, let me know if you think this is the type definition or my implementation.
1- I used import mongooseSoftDelete from "mongoose-softdelete";
instead of require, because with Require, TS seems to cast the plugin to a type of any (thus, deactivating TS type). So here is my first not-by-the-doc line.
2- I tried to import the plugin in my root mongoose file and apply this to the mongoose global object, like this:
mongoose.connect(uri, connectionParams);
mongoose.plugin(mongooseSoftDelete);
and It gives me this warning:
Argument of type 'typeof import("/home/user/work/project-api/node_modules/mongoose-softdelete/index")' is not assignable to parameter of type '(schema: Schema<any>) => void'.
Type 'typeof import("/home/user/work/projet-api/node_modules/mongoose-softdelete/index")' provides no match for the signature '(schema: Schema<any>): void'.ts(2345)
Note that even when I add the plugin directly to my schemas, It gives me the same warning.
Do you experience the same errors or does it looks like it is on my side?
Thanks for the help!
from mongoose-softdelete.
I resolved typing issue with this
import softDelete from 'mongoose-softdelete';
// ...
userSchema.plugin(softDelete as () => Schema<any>);
Also maybe it is simplier to make a PR on https://github.com/DefinitelyTyped/DefinitelyTyped ?
from mongoose-softdelete.
@madeindjs PRs are always welcomed 😃
from mongoose-softdelete.
@riyadhalnur , I made a simple PR 😉
from mongoose-softdelete.
Related Issues (10)
- View soft deleted objects in the database. HOT 1
- ERR_REQUIRE_ESM on running project
- ERR_REQUIRE_ESM on running project HOT 3
- Unknown types HOT 1
- Error [ERR_REQUIRE_ESM]: Must use import to load ES Module HOT 4
- Is it a good idea to use promise insteand of the old way callback
- Does this exclude soft deleted documents from queries? HOT 1
- should expose get calls HOT 1
- mongoose validating before softdelete HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongoose-softdelete.