Skip to content

Commit

Permalink
Update deleteFromCacheById, fixes #68
Browse files Browse the repository at this point in the history
  • Loading branch information
lorensr authored Jun 21, 2021
1 parent 0e25857 commit 9e84ece
Showing 1 changed file with 31 additions and 22 deletions.
53 changes: 31 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This package uses [DataLoader](https://github.com/graphql/dataloader) for batchi
- [findOneById](#findonebyid)
- [findManyByIds](#findmanybyids)
- [findByFields](#findbyfields)
- [Examples:](#examples)
- [Examples](#examples)
- [deleteFromCacheById](#deletefromcachebyid)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
Expand Down Expand Up @@ -246,35 +246,44 @@ Calls [`findOneById()`](#findonebyid) for each id. Resolves to an array of docum

Resolves to an array of documents matching the passed fields.

fields has type `{ [fieldName: string]: string | number | boolean | [string | number | boolean] }`.
`fields` has this type:

#### Examples:

```js
```ts
interface Fields {
[fieldName: string]:
| string
| number
| boolean
| ObjectId
| (string | number | boolean | ObjectId)[]
}
```

// get user by username
// `collection.find({ username: $in: ['testUser'] })`
this.getByFields({
username: 'testUser'
})
#### Examples

// get all users with either the "gaming" OR "games" interest
// `collection.find({ interests: $in: ['gaming', 'games'] })`
this.getByFields({
interests: ['gaming', 'games']
})
```js
// get user by username
// `collection.find({ username: $in: ['testUser'] })`
this.getByFields({
username: 'testUser'
})

// get user by username AND with either the "gaming" OR "games" interest
// `collection.find({ username: $in: ['testUser'], interests: $in: ['gaming', 'games'] })`
this.getByFields({
username: 'testUser',
interests: ['gaming', 'games']
})
// get all users with either the "gaming" OR "games" interest
// `collection.find({ interests: $in: ['gaming', 'games'] })`
this.getByFields({
interests: ['gaming', 'games']
})

// get user by username AND with either the "gaming" OR "games" interest
// `collection.find({ username: $in: ['testUser'], interests: $in: ['gaming', 'games'] })`
this.getByFields({
username: 'testUser',
interests: ['gaming', 'games']
})
```

### deleteFromCacheById

`this.deleteFromCacheById(id)`

Deletes a document from the cache.
Deletes a document from the cache that was fetched with `findOneById` or `findManyByIds`.

0 comments on commit 9e84ece

Please sign in to comment.