diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..b878825 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,20 @@ +declare module 'apollo-datasource-mongodb' { + import { DataSource, DataSourceConfig } from 'apollo-datasource' + import * as mongoose from 'mongoose' + + export { + DataSourceConfig + } + + interface Options { ttl: number } + + export abstract class MongoDataSource extends DataSource { + collection: mongoose.Collection + model?: mongoose.Model + constructor(collection: mongoose.Collection | mongoose.Model) + public initialize(config: DataSourceConfig): void + protected findOneById(id: string, { ttl }?: Options): T | null + protected findManyByIds(ids: string[], { ttl }?: Options): (T| null)[] + protected deleteFromCacheById(id: string): void + } +}