We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The type didn't want to resolve for me in typescript.
I had to add this in my project
typescript
declare module 'mongoose' { interface Query<ResultType, DocType, THelpers, RawDocType> { cache(ttl: number, customKey: string): this cache(customKey: string): this cache(ttl: number): this } }
I think the issue is that the interface in the library is DocumentQuery while in mongoose I'm using it's Query
DocumentQuery
Query
I'm using mongoose 7.1.0 recachegoose 11.0.0 pnpm 8.15.8 Node v18.18.0
The text was updated successfully, but these errors were encountered:
I'm keep thinking that if I remove the DocumentQuery, it might be not backwards compatible.
So if you add another interface then it works to you?
I've modified this typescript, but I just can't test it, can you help me to make sure this below index.d.ts works?
Here is the full modified index.d.ts
import { Document, Mongoose } from 'mongoose' // Declare the 'recachegoose' module declare module 'recachegoose' { function cachegoose(mongoose: Mongoose, cacheOptions: cachegoose.IOptions): void namespace cachegoose { interface IOptions { engine?: string count?: number port?: number host?: string password?: string client?: any } function clearCache(customKey: any, cb: (err: any) => void): void } export = cachegoose } // Augment the 'mongoose' module declare module 'mongoose' { interface DocumentQuery<T, DocType extends Document, QueryHelpers = {}> { // Not cachegoose related fix, but useful. Thanks to https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34205#issuecomment-621976826 orFail(err?: Error | (() => Error)): DocumentQuery<NonNullable<T>, DocType, QueryHelpers> cache(ttl?: number, customKey?: string): this } interface Query<ResultType, DocType extends Document, THelpers = {}, RawDocType = {}> { cache(ttl?: number, customKey?: string): this } } `` If you or anyone reading this issue, saying this is works, then I'll deliver the new update. Thank you.
Sorry, something went wrong.
Not working here as well.
No branches or pull requests
The type didn't want to resolve for me in typescript.
I had to add this in my project
typescript
I think the issue is that the interface in the library is
DocumentQuery
while in mongoose I'm using it'sQuery
I'm using mongoose 7.1.0
recachegoose 11.0.0
pnpm 8.15.8
Node v18.18.0
The text was updated successfully, but these errors were encountered: