Skip to content

Commit 9282142

Browse files
authored
Support ObjectID in findByFields Type (#67)
The TypeScript type for `findByFields()` didn't include `ObjectID` as a valid parameter, even though there are automated tests for it and it definitely is valid to do this in MongoDB. Update the type to reflect what's actually going on.
1 parent 5d7348b commit 9282142

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

index.d.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ declare module 'apollo-datasource-mongodb' {
44
import {
55
Collection as MongooseCollection,
66
Document,
7-
Model as MongooseModel
7+
Model as MongooseModel,
88
} from 'mongoose'
99

1010
export type Collection<T, U = MongoCollection<T>> = T extends Document
@@ -16,9 +16,14 @@ declare module 'apollo-datasource-mongodb' {
1616
export type ModelOrCollection<T> = T extends Document
1717
? Model<T>
1818
: Collection<T>
19-
19+
2020
export interface Fields {
21-
[fieldName: string]: string | number | boolean | (string | number | boolean)[]
21+
[fieldName: string]:
22+
| string
23+
| number
24+
| boolean
25+
| ObjectId
26+
| (string | number | boolean | ObjectId)[]
2227
}
2328

2429
export interface Options {

0 commit comments

Comments
 (0)