šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

prisma-extension-create-with-slug

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prisma-extension-create-with-slug

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

0.0.6
latest
Source
npm
Version published
Weekly downloads
18
-65.38%
Maintainers
1
Weekly downloads
Ā 
Created
Source

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

Keywords

prisma

FAQs

Package last updated on 03 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts