Skip to content

Commit e2944e0

Browse files
committed
Update README
1 parent fb98286 commit e2944e0

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,6 @@
66

77
A Prisma extension that automatically adds prefixed IDs to your models. This package allows you to configure custom prefixes for your models and even customize how the IDs are generated.
88

9-
## Why nanoid instead of UUID v4?
10-
11-
This package uses [nanoid](https://github.com/ai/nanoid) for ID generation instead of UUID v4 for several reasons:
12-
13-
1. **Better Collision Resistance**: While UUID v4 has a 122-bit random component, nanoid with 24 characters (using 36 possible characters) provides approximately 128 bits of entropy, making it even more collision-resistant than UUID v4.
14-
15-
2. **Smaller Size**: A UUID v4 is 36 characters long (including hyphens), while a nanoid with 24 characters is more compact. When combined with a prefix (e.g., `usr_`), the total length is still shorter than a UUID v4.
16-
17-
3. **URL-Safe**: nanoid uses URL-safe characters by default, making it suitable for use in URLs without encoding.
18-
19-
4. **Customizable**: nanoid allows you to customize the alphabet and length, giving you more control over the ID format.
20-
21-
5. **Better Performance**: nanoid is optimized for performance and generates IDs faster than UUID v4.
22-
23-
For example, with a 24-character nanoid:
24-
- The chance of a collision is approximately 1 in 2^128 (same as UUID v4)
25-
- The ID length is 24 characters + prefix length (e.g., `usr_abc123...`)
26-
- The alphabet includes 36 characters (0-9, a-z), making it both readable and compact
27-
289
## Installation
2910

3011
```bash
@@ -122,6 +103,25 @@ The `idGenerator` function should:
122103

123104
The default generator uses nanoid with a 24-character length and alphanumeric characters.
124105

106+
## Why nanoid instead of UUID v4?
107+
108+
This package uses [nanoid](https://github.com/ai/nanoid) for ID generation instead of UUID v4 for several reasons:
109+
110+
1. **Better Collision Resistance**: While UUID v4 has a 122-bit random component, nanoid with 24 characters (using 36 possible characters) provides approximately 128 bits of entropy, making it even more collision-resistant than UUID v4.
111+
112+
2. **Smaller Size**: A UUID v4 is 36 characters long (including hyphens), while a nanoid with 24 characters is more compact. When combined with a prefix (e.g., `usr_`), the total length is still shorter than a UUID v4.
113+
114+
3. **URL-Safe**: nanoid uses URL-safe characters by default, making it suitable for use in URLs without encoding.
115+
116+
4. **Customizable**: nanoid allows you to customize the alphabet and length, giving you more control over the ID format.
117+
118+
5. **Better Performance**: nanoid is optimized for performance and generates IDs faster than UUID v4.
119+
120+
For example, with a 24-character nanoid:
121+
- The chance of a collision is approximately 1 in 2^128 (same as UUID v4)
122+
- The ID length is 24 characters + prefix length (e.g., `usr_abc123...`)
123+
- The alphabet includes 36 characters (0-9, a-z), making it both readable and compact
124+
125125
## License
126126

127127
MIT

0 commit comments

Comments
 (0)