@@ -26,7 +26,7 @@ This package uses [DataLoader](https://github.com/graphql/dataloader) for batchi
26
26
- [ findOneById] ( #findonebyid )
27
27
- [ findManyByIds] ( #findmanybyids )
28
28
- [ findByFields] ( #findbyfields )
29
- - [ Examples: ] ( #examples )
29
+ - [ Examples] ( #examples )
30
30
- [ deleteFromCacheById] ( #deletefromcachebyid )
31
31
32
32
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -246,35 +246,44 @@ Calls [`findOneById()`](#findonebyid) for each id. Resolves to an array of docum
246
246
247
247
Resolves to an array of documents matching the passed fields.
248
248
249
- fields has type ` { [fieldName: string]: string | number | boolean | [string | number | boolean] } ` .
249
+ ` fields ` has this type:
250
250
251
- #### Examples:
252
-
253
- ``` js
251
+ ``` ts
252
+ interface Fields {
253
+ [fieldName : string ]:
254
+ | string
255
+ | number
256
+ | boolean
257
+ | ObjectId
258
+ | (string | number | boolean | ObjectId )[]
259
+ }
260
+ ```
254
261
255
- // get user by username
256
- // `collection.find({ username: $in: ['testUser'] })`
257
- this .getByFields ({
258
- username: ' testUser'
259
- })
262
+ #### Examples
260
263
261
- // get all users with either the "gaming" OR "games" interest
262
- // `collection.find({ interests: $in: ['gaming', 'games'] })`
263
- this .getByFields ({
264
- interests: [' gaming' , ' games' ]
265
- })
264
+ ``` js
265
+ // get user by username
266
+ // `collection.find({ username: $in: ['testUser'] })`
267
+ this .getByFields ({
268
+ username: ' testUser'
269
+ })
266
270
267
- // get user by username AND with either the "gaming" OR "games" interest
268
- // `collection.find({ username: $in: ['testUser'], interests: $in: ['gaming', 'games'] })`
269
- this .getByFields ({
270
- username: ' testUser' ,
271
- interests: [' gaming' , ' games' ]
272
- })
271
+ // get all users with either the "gaming" OR "games" interest
272
+ // `collection.find({ interests: $in: ['gaming', 'games'] })`
273
+ this .getByFields ({
274
+ interests: [' gaming' , ' games' ]
275
+ })
273
276
277
+ // get user by username AND with either the "gaming" OR "games" interest
278
+ // `collection.find({ username: $in: ['testUser'], interests: $in: ['gaming', 'games'] })`
279
+ this .getByFields ({
280
+ username: ' testUser' ,
281
+ interests: [' gaming' , ' games' ]
282
+ })
274
283
```
275
284
276
285
### deleteFromCacheById
277
286
278
287
` this.deleteFromCacheById(id) `
279
288
280
- Deletes a document from the cache.
289
+ Deletes a document from the cache that was fetched with ` findOneById ` or ` findManyByIds ` .
0 commit comments