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
Copy file name to clipboardExpand all lines: docs/database/transactions.mdx
+16-1Lines changed: 16 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ desc: Database transactions are fully supported within Payload.
8
8
9
9
Database transactions allow your application to make a series of database changes in an all-or-nothing commit. Consider an HTTP request that creates a new **Order** and has an `afterChange` hook to update the stock count of related **Items**. If an error occurs when updating an **Item** and an HTTP error is returned to the user, you would not want the new **Order** to be persisted or any other items to be changed either. This kind of interaction with the database is handled seamlessly with transactions.
10
10
11
-
By default, Payload will use transactions for all operations, as long as it is supported by the configured database. Database changes are contained within all Payload operations and any errors thrown will result in all changes being rolled back without being committed. When transactions are not supported by the database, Payload will continue to operate as expected without them.
11
+
By default, Payload will use transactions for all data changing operations, as long as it is supported by the configured database. Database changes are contained within all Payload operations and any errors thrown will result in all changes being rolled back without being committed. When transactions are not supported by the database, Payload will continue to operate as expected without them.
12
12
13
13
<Bannertype="info">
14
14
<strong>Note:</strong>
@@ -114,3 +114,18 @@ standalonePayloadScript()
114
114
## Disabling Transactions
115
115
116
116
If you wish to disable transactions entirely, you can do so by passing `false` as the `transactionOptions` in your database adapter configuration. All the official Payload database adapters support this option.
117
+
118
+
In addition to allowing database transactions to be disabled at the adapter level. You can prevent Payload from using a transaction in direct calls to the local API by adding `disableTransaction: true` to the args. For example:
Copy file name to clipboardExpand all lines: docs/local-api/overview.mdx
+15-14Lines changed: 15 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,20 +77,21 @@ Both options function in exactly the same way outside of one having HMR support
77
77
78
78
You can specify more options within the Local API vs. REST or GraphQL due to the server-only context that they are executed in.
79
79
80
-
| Local Option | Description |
81
-
| ------------------ | ------------ |
82
-
|`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
-
|`overrideLock`| By default, document locks are ignored (`true`). Set to `false` to enforce locks and prevent operations when a document is locked by another user. [More details](../admin/locked-documents).|
89
-
|`user`| If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks. |
90
-
|`showHiddenFields`| Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config. |
91
-
|`pagination`| Set to false to return all documents and avoid querying for document counts. |
92
-
|`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. |
93
-
|`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. |
|`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
+
|`overrideLock`| By default, document locks are ignored (`true`). Set to `false` to enforce locks and prevent operations when a document is locked by another user. [More details](../admin/locked-documents). |
89
+
|`user`| If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks. |
90
+
|`showHiddenFields`| Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config. |
91
+
|`pagination`| Set to false to return all documents and avoid querying for document counts. |
92
+
|`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. |
93
+
|`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. |
94
+
|`disableTransaction`| When set to `true`, a [database transactions](../database/transactions) will not be initialized. |
94
95
95
96
_There are more options available on an operation by operation basis outlined below._
0 commit comments