How to implement automatic Custom ID? #5878
-
Collection config allow me to overwrite payload ID implement, but can't define Would like to fully customize using nanoID but any ID like, its totally fine. Is it possible? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hey @didiraja, I was surprised that defaultValue is not allowed for custom ID fields. As another workaround you could add it to the beforeValidate hook like this:
|
Beta Was this translation helpful? Give feedback.
-
@DanRibbens This is how Payload reacts when I try to overwrite id object using defaultValue: collection definition:
terminal output:
|
Beta Was this translation helpful? Give feedback.
Hey @didiraja,
I was surprised that defaultValue is not allowed for custom ID fields. As another workaround you could add it to the beforeValidate hook like this: