unique-slugify
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

Indroduction

This package provides functionality to generate unique slugs or unique IDs in Node js or ts applications.

Installation

   npm i unique-slugify

   import { generateUniqueSlug } from 'unique-slugify    

Usage

node

---- Javascript and Typescript ---

we can use various scenarios in case of we need to generate unique id as a slug for documents for you can check it out :- other scenarios like need of random unique number you can also you this ;

    const uniqueId = generateUniqueSlug();

Example Usage : ( for generating unique id for each document as like ID - use as slug )

  const ProductSchema: Schema = new Schema({
   name: { type: String, required: true },
   slug: { type: String, unique: true, index: true },
   description: { type: String, required: true }
});
ProductSchema.pre<Product>('save', async function (next) {
const slug = generateUniqueSlug();
this.slug = slug;
next();
});     
    ```

Package Sidebar

Install

npm i unique-slugify

Weekly Downloads

2

Version

1.0.6

License

MIT

Unpacked Size

6.53 kB

Total Files

7

Last publish

Collaborators

  • jabirhussain-at