Skip to content

Commit 7c39d2f

Browse files
committed
README updated
1 parent 8a99bbe commit 7c39d2f

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Prageeth Silva
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
11
# Prisma Prefixed IDs
22

3+
[![npm version](https://img.shields.io/npm/v/prisma-prefixed-ids.svg)](https://www.npmjs.com/package/prisma-prefixed-ids)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5+
[![Build Status](https://github.com/pureartisan/prisma-prefixed-ids/actions/workflows/ci.yml/badge.svg)](https://github.com/pureartisan/prisma-prefixed-ids/actions/workflows/ci.yml)
6+
[![codecov](https://codecov.io/gh/pureartisan/prisma-prefixed-ids/branch/main/graph/badge.svg)](https://codecov.io/gh/pureartisan/prisma-prefixed-ids)
7+
38
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.
49

10+
## Why nanoid instead of UUID v4?
11+
12+
This package uses [nanoid](https://github.com/ai/nanoid) for ID generation instead of UUID v4 for several reasons:
13+
14+
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.
15+
16+
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.
17+
18+
3. **URL-Safe**: nanoid uses URL-safe characters by default, making it suitable for use in URLs without encoding.
19+
20+
4. **Customizable**: nanoid allows you to customize the alphabet and length, giving you more control over the ID format.
21+
22+
5. **Better Performance**: nanoid is optimized for performance and generates IDs faster than UUID v4.
23+
24+
For example, with a 24-character nanoid:
25+
- The chance of a collision is approximately 1 in 2^128 (same as UUID v4)
26+
- The ID length is 24 characters + prefix length (e.g., `usr_abc123...`)
27+
- The alphabet includes 36 characters (0-9, a-z), making it both readable and compact
28+
529
## Installation
630

731
```bash

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
77
"type": "module",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/pureartisan/prisma-prefixed-ids"
11+
},
812
"scripts": {
913
"build": "tsc",
1014
"prepare": "npm run build",
@@ -24,7 +28,7 @@
2428
"prefixed",
2529
"nanoid"
2630
],
27-
"author": "Prageeth Silva <prageeth@codemode.com.au>",
31+
"author": "Prageeth Silva <prageethsilva@gmail.com>",
2832
"license": "MIT",
2933
"dependencies": {
3034
"@prisma/client": "^5.0.0",

0 commit comments

Comments
 (0)