You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: findByID adjust type to null if disableErrors: true is passed (#8282)
Fixes#8280
Now, the result type of this operation:
```ts
const post = await payload.findByID({
collection: "posts",
id,
disableErrors: true
})
```
is `Post | null` instead of `Post` when `disableErrors: true` is passed
Adds test for the `disableErrors` property and docs.
|`collection`| Required for Collection operations. Specifies the Collection slug to operate against. |
83
+
|`data`| The data to use within the operation. Required for `create`, `update`. |
84
+
|`depth`|[Control auto-population](../queries/depth) of nested relationship and upload fields. |
85
+
|`locale`| Specify [locale](/docs/configuration/localization) for any returned documents. |
86
+
|`fallbackLocale`| Specify a [fallback locale](/docs/configuration/localization) to use for any returned documents. |
87
+
|`overrideAccess`| Skip access control. By default, this property is set to true within all Local API operations. |
88
+
|`user`| If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks. |
89
+
|`showHiddenFields`| Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config. |
90
+
|`pagination`| Set to false to return all documents and avoid querying for document counts. |
91
91
|`context`|[Context](/docs/hooks/context), which will then be passed to `context` and `req.context`, which can be read by hooks. Useful if you want to pass additional information to the hooks which shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook to determine if it should run or not. |
92
+
|`disableErrors`| When set to `true`, errors will not be thrown. Instead, the `findByID` operation will return `null`, and the `find` operation will return an empty documents array. |
92
93
93
94
_There are more options available on an operation by operation basis outlined below._
0 commit comments