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
feat(db-mongodb): allow to customize mongoose schema options with collectionsSchemaOptions (#9885)
Adds the ability to pass additional schema options for collections with:
```ts
mongooseAdapter({
collectionsSchemaOptions: {
posts: {
strict: false,
},
},
})
```
This changes relates to these:
- #4533
- #4534
It is a proposal to set custom schema options for mongoose driver.
I understand this got introduced into `main` v2 after `beta` branch was
created so this feature got lost.
- [x] I have read and understand the
[CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md)
document in this repository.
<!--
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: Sasha <64744993+r1tsuu@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/database/mongodb.mdx
+9-8Lines changed: 9 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -30,14 +30,15 @@ export default buildConfig({
30
30
31
31
## Options
32
32
33
-
| Option | Description |
34
-
| -------------------- | ----------- |
35
-
|`autoPluralization`| Tell Mongoose to auto-pluralize any collection names if it encounters any singular words used as collection `slug`s. |
36
-
|`connectOptions`| Customize MongoDB connection options. Payload will connect to your MongoDB database using default options which you can override and extend to include all the [options](https://mongoosejs.com/docs/connections.html#options) available to mongoose. |
37
-
|`disableIndexHints`| Set to true to disable hinting to MongoDB to use 'id' as index. This is currently done when counting documents for pagination, as it increases the speed of the count function used in that query. Disabling this optimization might fix some problems with AWS DocumentDB. Defaults to false |
38
-
|`migrationDir`| Customize the directory that migrations are stored. |
39
-
|`transactionOptions`| An object with configuration properties used in [transactions](https://www.mongodb.com/docs/manual/core/transactions/) or `false` which will disable the use of transactions. |
40
-
|`collation`| Enable language-specific string comparison with customizable options. Available on MongoDB 3.4+. Defaults locale to "en". Example: `{ strength: 3 }`. For a full list of collation options and their definitions, see the [MongoDB documentation](https://www.mongodb.com/docs/manual/reference/collation/). |
|`autoPluralization`| Tell Mongoose to auto-pluralize any collection names if it encounters any singular words used as collection `slug`s. |
36
+
|`connectOptions`| Customize MongoDB connection options. Payload will connect to your MongoDB database using default options which you can override and extend to include all the [options](https://mongoosejs.com/docs/connections.html#options) available to mongoose. |
37
+
|`collectionsSchemaOptions`| Customize Mongoose schema options for collections. |
38
+
|`disableIndexHints`| Set to true to disable hinting to MongoDB to use 'id' as index. This is currently done when counting documents for pagination, as it increases the speed of the count function used in that query. Disabling this optimization might fix some problems with AWS DocumentDB. Defaults to false |
39
+
|`migrationDir`| Customize the directory that migrations are stored. |
40
+
|`transactionOptions`| An object with configuration properties used in [transactions](https://www.mongodb.com/docs/manual/core/transactions/) or `false` which will disable the use of transactions. |
41
+
|`collation`| Enable language-specific string comparison with customizable options. Available on MongoDB 3.4+. Defaults locale to "en". Example: `{ strength: 3 }`. For a full list of collation options and their definitions, see the [MongoDB documentation](https://www.mongodb.com/docs/manual/reference/collation/). |
/** Set false to disable $facet aggregation in non-supporting databases, Defaults to true */
85
94
useFacet?: boolean
86
95
}&ConnectOptions
87
-
88
96
/** Set to true to disable hinting to MongoDB to use 'id' as index. This is currently done when counting documents for pagination. Disabling this optimization might fix some problems with AWS DocumentDB. Defaults to false */
89
97
disableIndexHints?: boolean
90
98
/**
@@ -103,6 +111,7 @@ export interface Args {
103
111
up: (args: MigrateUpArgs)=>Promise<void>
104
112
}[]
105
113
transactionOptions?: false|TransactionOptions
114
+
106
115
/** The URL to connect to MongoDB or false to start payload and prevent connecting */
107
116
url: false|string
108
117
}
@@ -163,6 +172,7 @@ declare module 'payload' {
163
172
164
173
exportfunctionmongooseAdapter({
165
174
autoPluralization =true,
175
+
collectionsSchemaOptions ={},
166
176
connectOptions,
167
177
disableIndexHints =false,
168
178
ensureIndexes,
@@ -194,6 +204,7 @@ export function mongooseAdapter({
0 commit comments