Currently in the process of migrating to to postgres after the announcement about dropping mongodb, Just noticed that the ID's are just numbers and auto-incremented.
I have tried:
- Setting the default ID as a UUID with a lifecycle hook - No effect
- Installing bookshelf-uuid
Anyone know how to do this? I very much do not want the ID of my post to be an auto-incremented number.
Auto-incremented ids and uuids are in general a different concept. For uuids as primary key one often uses random values. Due to the large range of values, duplicates are almost impossible.
You can define an auto-generated uuid primary key as follows:
The pgcrypto extension provides a function for creating random uuids as well.
With Postgres 13 the creation of the pgcrypto extension for using
gen_random_uuid()isn't necessary anymore.