Skip to content

Commit c4375bd

Browse files
docs: add warning about Cosmos dB incompatibility (#13350)
Update the docs to warn about Cosmos dB incompatibility with payload, <!-- Thank you for the PR! Please go through the checklist below and make sure you've completed all the steps. Please review the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository if you haven't already. The following items will ensure that your PR is handled as smoothly as possible: - PR Title must follow conventional commits format. For example, `feat: my new feature`, `fix(plugin-seo): my fix`. - Minimal description explained as if explained to someone not immediately familiar with the code. - Provide before/after screenshots or code diffs if applicable. - Link any related issues/discussions from GitHub or Discord. - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Fixes # --> --------- Co-authored-by: Paul Popus <paul@payloadcms.com> Co-authored-by: Paul <paul@nouance.io>
1 parent 14b708f commit c4375bd

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

docs/production/deployment.mdx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,36 @@ unsupported `$facet` aggregation.
8282

8383
### CosmosDB
8484

85-
When using Azure Cosmos DB, an index is needed for any field you may want to sort on. To add the sort index for all
86-
fields that may be sorted in the admin UI use the [indexSortableFields](/docs/configuration/overview) option.
85+
<Banner type="warning">
86+
While Azure Cosmos DB offers a MongoDB API it is not fully compatible due to strict and limited indexing behavior and many core features may not work reliably. For more details, see the [MongoDB driver's CosmosDB compatibility documentation](https://www.mongodb.com/docs/drivers/cosmosdb-support/#compatibility).
87+
</Banner>
88+
89+
To improve compatibility, spread the `compatibilityOptions.cosmosdb` preset into your adapter. This applies all recommended settings at once:
90+
91+
```ts
92+
import { mongooseAdapter, compatibilityOptions } from '@payloadcms/db-mongodb'
93+
94+
export default buildConfig({
95+
db: mongooseAdapter({
96+
url: process.env.DATABASE_URL,
97+
...compatibilityOptions.cosmosdb,
98+
indexSortableFields: true,
99+
}),
100+
})
101+
```
102+
103+
#### What `compatibilityOptions.cosmosdb` enables
104+
105+
For advanced use cases, you can apply these options individually instead of spreading the preset:
106+
107+
| Option | Value | Purpose |
108+
| --------------------------------- | ------- | ----------------------------------------------------------------------------- |
109+
| `bulkOperationsSingleTransaction` | `true` | Processes bulk operations one at a time to avoid Cosmos DB transaction limits |
110+
| `transactionOptions` | `false` | Disables multi-document transactions (unsupported by Cosmos DB) |
111+
| `useJoinAggregations` | `false` | Uses multiple find queries instead of correlated subqueries |
112+
| `usePipelineInSortLookup` | `false` | Disables `$lookup` pipeline during sorting |
113+
114+
You can also add [`indexSortableFields`](/docs/configuration/overview) to index all sortable fields for the admin UI.
87115

88116
## File storage
89117

0 commit comments

Comments
 (0)