# prisma-extension-create-with-slug

> Prisma Client Extension to automatically generate a unique slug creating a new Database entry.

Latest version **0.0.6** (published 2025-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install prisma-extension-create-with-slug
pnpm add prisma-extension-create-with-slug
yarn add prisma-extension-create-with-slug
bun add prisma-extension-create-with-slug
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2025-04-03 |
| First published | 2023-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 18.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | mlmetzner |
| Maintainers | mlmetzner |
| Keywords | prisma, @prisma/client, extension, slugify, slug |

## Links

- npm: https://www.npmjs.com/package/prisma-extension-create-with-slug
- Repository: https://github.com/makkusubaito/prisma-autoslug-extension
- Homepage: https://github.com/makkusubaito/prisma-autoslug-extension#readme
- Issues: https://github.com/makkusubaito/prisma-autoslug-extension/issues
- npm.io page: https://npm.io/package/prisma-extension-create-with-slug

## Dependencies (1)

- [slugify](https://npm.io/package/slugify.md) ^1.6.6

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 0.0.6 (latest) — 2025-04-03
- 0.0.5 — 2023-11-01
- 0.0.4 — 2023-09-02
- 0.0.3 — 2023-09-02
- 0.0.2 — 2023-09-02
- 0.0.1 — 2023-09-02

## README

# prisma-extension-create-with-slug
## Description

Prisma Client Extension to automatically generate a unique slug creating a new Database entry. 

Provides a new function that generates a slug depending on a selected field. If needed the field can be unique.

## Install
```
npm install prisma-extension-create-with-slug
```

## Usage 

```
import {createWithSlugFn} from prisma-extension-create-with-slug

const prisma = new PrismaClient().$extends(createWithSlugFn())


  const post = await prisma.post.createWithSlug({data: 
    {
      title: "Hello World!",
      updatedAt: new Date(),
    },
     sourceField: "title",
     targetField: "slug",
    unique: true} 
   )


```

## Options 

```
await prisma.YOUR_MODEL.createWithSlug({
    data: {
        ...
    },
    sourceField: 'FIELDNAME' or ['FIELDNAME1', 'FIELDNAME2'] // name of the field(s) you want the slug to be based on
    targetField: 'FIELDNAME' // name of the field the slug should be written to
    unique: true       // whether or not the slug should be unique (increments an integer after the slug)
})

```

## Dependencies

[slugify] (https://github.com/simov/slugify)
create with the [prisma extension starter](https://github.com/prisma/prisma-client-extension-starter)

---
_Source: https://npm.io/package/prisma-extension-create-with-slug · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
