aalfiann / recachegoose

A Mongoose caching module that works exactly how you would expect it to, with the latest version of Mongoose.
https://nodei.co/npm/recachegoose
MIT License
26 stars 14 forks source link

Property 'cache' does not exist #11

Closed Rahuletto closed 1 year ago

Rahuletto commented 1 year ago
Property 'cache' does not exist on type 'Query<Document<unknown, {}, { files: DocumentArray<any> | any[] | { [x: string]: any; }[] | any[]; options: DocumentArray<any> | any[] | { [x: string]: any; }[] | any[]; key?: unknown; name?: unknown; description?: unknown; createdAt?: unknown; }> & Omit<...>, Document<...> & Omit<...>, {}, { ...; }, "findOne">'. Did you mean 'catch'? ts(2551)

This can be simply said that Query.cache() is not a function.

Versions:

"mongoose": "^7.2.2",
"recachegoose": "^9.2.0"

Reproduction

(Using Typescript)

import cachegoose from 'recachegoose';

cachegoose(mongoose, { engine: 'memory' });


- fetch.ts
```ts
const result: Board = await Schema.findOne({ key: queries.id }).cache(0);

ERROR:

const result: Board = await Schema.findOne({ key: queries.id }).cache(0);
                                                                ^^^^^
Property 'cache' does not exist on type 'Query<Document<unknown, {}, { files: DocumentArray<any> | any[] | { [x: string]: any; }[] | any[]; options: DocumentArray<any> | any[] | { [x: string]: any; }[] | any[]; key?: unknown; name?: unknown; description?: unknown; createdAt?: unknown; }> & Omit<...>, Document<...> & Omit<...>, {}, { ...; }, "findOne">'. Did you mean 'catch'?

Edit: Tried with a implementation similar to your documentation README.md. Its the same

Schema.findOne({ key: queries.id }).cache(0).exec(function(err, records) { console.log('Yay i work') });
Property 'cache' does not exist on type 'Query<Document<unknown, {}, { files: DocumentArray<any> | any[] | { [x: string]: any; }[] | any[]; options: DocumentArray<any> | any[] | { [x: string]: any; }[] | any[]; key?: unknown; name?: unknown; description?: unknown; createdAt?: unknown; }> & Omit<...>, Document<...> & Omit<...>, {}, { ...; }, "findOne">'. Did you mean 'catch'?
aalfiann commented 1 year ago

Have you tried with the latest version? coz there is someone has created the PR 2 weeks ago.

Rahuletto commented 1 year ago

I'm sorry I moved to an entirely new database now. Thank you if you fixed it.