Replies: 1 comment
-
|
The await pb.collection("example").create({
id: "YOUR_CUSTOM_ID", // it is always string
})If you want to set the custom id automatically with a server-side hook, then this could be done with something like:
You can adjust the allowed length and regex validators from the specific field options in the collection panel: With that said, the better question is - why would you want to use UUIDv7 and what do you think would be the benefit of doing that? If you don't have a good reason, my recommendation would be to stick with the default one. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I hope you're all doing well.
I would like to ask if it’s possible to have PocketBase automatically generate record IDs using UUIDv7 instead of the default 15-character alphanumeric IDs.
I’ve looked through the documentation but couldn’t find a built-in option for changing the ID generation strategy. My goal is to have every new record in a collection use a UUIDv7 as its primary ID.
Is there a recommended way to implement this? For example:
Using a before-create hook in a custom PocketBase js backend?
Any simple example code on how to override the default ID generator?
A small, easy-to-understand example would be greatly appreciated.
Thank you so much for your help!
Beta Was this translation helpful? Give feedback.
All reactions