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-*): allow to thread id to create operation data without custom IDs (#11709)
Fixes#6884
Adds a new flag `acceptIDOnCreate` that allows you to thread your own
`id` to `payload.create` `data`, for example:
```ts
// doc created with id 1
const doc = await payload.create({ collection: 'posts', data: {id: 1, title: "my title"}})
```
```ts
import { Types } from 'mongoose'
const id = new Types.ObjectId().toHexString()
const doc = await payload.create({ collection: 'posts', data: {id, title: "my title"}})
```
Copy file name to clipboardExpand all lines: docs/database/mongodb.mdx
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,7 @@ export default buildConfig({
40
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
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/). |
42
42
|`allowAdditionalKeys`| By default, Payload strips all additional keys from MongoDB data that don't exist in the Payload schema. If you have some data that you want to include to the result but it doesn't exist in Payload, you can set this to `true`. Be careful as Payload access control _won't_ work for this data. |
43
+
|`allowIDOnCreate`| Set to `true` to use the `id` passed in data on the create API operations without using a custom ID field. |
Copy file name to clipboardExpand all lines: docs/database/sqlite.mdx
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,7 @@ export default buildConfig({
49
49
|`afterSchemaInit`| Drizzle schema hook. Runs after the schema is built. [More Details](#afterschemainit)|
50
50
|`generateSchemaOutputFile`| Override generated schema from `payload generate:db-schema` file path. Defaults to `{CWD}/src/payload-generated.schema.ts`|
51
51
|`autoIncrement`| Pass `true` to enable SQLite [AUTOINCREMENT](https://www.sqlite.org/autoinc.html) for primary keys to ensure the same ID cannot be reused from deleted rows |
52
+
|`allowIDOnCreate`| Set to `true` to use the `id` passed in data on the create API operations without using a custom ID field. |
0 commit comments