There are many ways to handle ID generation in PostgreSQL, but I’ve chosen to investigate these four approaches:
- Auto-incrementing (
SERIAL
data type) - Sequence-caching
- Sequence-incrementing with client-side ID management
- UUID-generation
Depending on your application and your underlying database tables, you might choose to employ one or more of these options. Below, I’ll explain how each can be achieved in Node.js using the Sequelize ORM.