File tree Expand file tree Collapse file tree 3 files changed +1694
-1580
lines changed Expand file tree Collapse file tree 3 files changed +1694
-1580
lines changed Original file line number Diff line number Diff line change
1
+ declare module 'apollo-datasource-mongodb' {
2
+ import { DataSource } from 'apollo-datasource'
3
+ import { Collection as MongoCollection , ObjectId } from 'mongodb'
4
+ import {
5
+ Collection as MongooseCollection ,
6
+ Document ,
7
+ Model as MongooseModel
8
+ } from 'mongoose'
9
+
10
+ export type Collection < T > = T extends Document
11
+ ? MongooseCollection
12
+ : MongoCollection < T >
13
+
14
+ export type Model < T > = T extends Document ? MongooseModel < T > : undefined
15
+
16
+ export type ModelOrCollection < T > = T extends Document
17
+ ? Model < T >
18
+ : Collection < T >
19
+
20
+ export interface Options {
21
+ ttl : number
22
+ }
23
+
24
+ export class MongoDataSource < TData , TContext = any > extends DataSource <
25
+ TContext
26
+ > {
27
+ protected context : TContext
28
+ protected collection : Collection < TData >
29
+ protected model : Model < TData >
30
+
31
+ constructor ( modelOrCollection : ModelOrCollection < TData > )
32
+
33
+ findOneById (
34
+ id : ObjectId ,
35
+ options ?: Options
36
+ ) : Promise < TData | null | undefined >
37
+
38
+ findManyByIds (
39
+ ids : ObjectId [ ] ,
40
+ options ?: Options
41
+ ) : Promise < ( TData | null | undefined ) [ ] >
42
+
43
+ deleteFromCacheById ( id : ObjectId ) : void
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments