docs: corrections to field hooks

This commit is contained in:
James
2021-03-14 12:59:12 -04:00
parent 3c42e6e6af
commit 39b30da10f

View File

@@ -48,7 +48,7 @@ All field-level hooks are formatted to accept the same arguments, although some
<Banner type="success">
<strong>Tip:</strong><br />
It's a good idea to conditionally scope your logic based on which operation is executing.
It's a good idea to conditionally scope your logic based on which operation is executing. For example, if you are writing a <code>beforeChange</code> hook, you may want to perform different logic based on if the current <code>operation</code> is <code>create</code> or <code>update</code>.
</Banner>
#### Arguments
@@ -57,10 +57,10 @@ Field Hooks receive one `args` argument that contains the following properties:
| Option | Description |
| ----------------- | -------------|
| **`value`** | The value of the field, before any updating. Will return `undefined` within `create` operations. |
| **`data`** | The data passed to update the field with in `create` and `update` operations. |
| **`originalDoc`** | The full original document in `update` or `read` operations. |
| **`operation`** | A string relating to which operation the field type is currently executing within. |
| **`value`** | The value of the field. |
| **`data`** | The data passed to update the field with in `create` and `update` operations, and the full document itself in the `afterRead` hook. |
| **`originalDoc`** | The full original document in `update` operations. |
| **`operation`** | A string relating to which operation the field type is currently executing within. Useful within `beforeValidate`, `beforeChange`, and `afterChange` hooks to differentiate between `create` and `update` operations. |
| **`req`** | The Express `request` object. It is mocked for Local API operations. |
#### Return value