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

Add typescript support #67

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
36 changes: 36 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Document, Mongoose } from 'mongoose';

declare module 'cachegoose' {

function cachegoose(mongoose: Mongoose, cacheOptions: cachegoose.Types.IOptions): void;

namespace cachegoose {
namespace Types {
interface IOptions {
engine?: string
port?: number
host?: string
}
}

function clearCache(customKey: any, cb: any): void;
}
// @ts-ignore
export = cachegoose;
}

// @ts-ignore
declare module 'mongoose' {
// eslint-disable-next-line @typescript-eslint/class-name-casing
interface DocumentQuery<T, DocType extends Document, QueryHelpers = {}> {
// @ts-ignore
cache(ttl: number = 60, customKey: string = ''): this

// @ts-ignore
cache(customKey: string = ''): this

// @ts-ignore
cache(ttl: number = 60): this
}
}

Loading