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
It would be useful if this could be supported for all documents having an id value set. For instance cross-referenced collection documents could be created without having to wait for the IDs and an update operation afterwards.
Describe the Bug
I have bunch of code that now doesn't work because the id param in
.create()
is ignored and new id is generated:In payload 2.0 I would have to use
_id
as the property to set the id, after 3.0, I had to switch using 'id'Now it not working at all.
A simple example of my use of this is in a
beforeChange
hook for aUsers
collection.On a create operation:
In this simple example I could just
await
the creating the calendar-settings but my real use case I can not do this.Like I said this used to work fine and payload's type for says I can pass in an
id
field.Its removed as required and added back in to the data type as optional.
I used the mongo db adapter.
I am pretty sure the
_id
change toid
in payload 3.0 was due to Payload starting to actually use ObjectID objects.Also I can hack this to work if in the
calendar-settings
before change hook I do this:From the payload code it appears the issue is that is because data is passed directly in the db adapter and mongo db needs
_id
: https://github.com/payloadcms/payload/blob/main/packages/payload/src/collections/operations/create.ts#L268Link to the code that reproduces this issue
https://github.com/cgilly2fast/payload/tree/id-issue
Reproduction Steps
Create new user
Which area(s) are affected? (Select all that apply)
area: core
Environment Info
The text was updated successfully, but these errors were encountered: