Repository-Metriken
- Stars
- (29.527 Sterne)
- PR-Merge-Metriken
- (Durchschn. Merge 5h 24m) (1 gemergte PR in 30 T)
Beschreibung
Issue Creation Checklist
- I understand that my issue will be automatically closed if I don't fill in the requested information
- I have read the contribution guidelines
Feature Description
Describe the feature you'd like to see implemented
Add native support for generating UUIDv7 values without requiring the external uuid npm package. Node.js has native crypto.randomUUID() for v4-style UUIDs, and native UUIDv7 generation is landing in newer Node versions (see https://github.com/nodejs/node/issues/62529). PostgreSQL has also added native UUIDv7 generation support.
Example of the proposed usage:
```ts @Attribute(DataTypes.UUID) @PrimaryKey @Default(fn('uuidv7')) declare id: CreationOptional; ```
This would let users generate time-ordered, sortable UUIDs as primary keys directly through Sequelize's fn() helper, similar to how UUIDV4 is currently supported.
Describe why you would like this feature to be added to Sequelize
Sequelize currently depends on the external uuid package for UUID generation, which has caused ESM/CommonJS interoperability issues in the past (see #18224, fixed via #18230). Native UUIDv7 support would reduce this dependency surface for a very common use case (time-sortable primary keys) and align Sequelize with what Node.js and PostgreSQL are already offering natively. This was raised by @SippieCup during review of #18230, but is out of scope there since that PR targets the v6 branch, which still needs to support older Node versions.
Is this feature dialect-specific?
- No. This feature is relevant to Sequelize as a whole.
- Yes. This feature only applies to the following dialect(s):
Would you be willing to resolve this issue by submitting a Pull Request?
- Yes, I have the time and I know how to start.
- Yes, I have the time but I will need guidance.
- No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
- No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in implementing my feature.