UNPKG

@adonisjs/lucid-slugify

Version:

Generate and persist unique slugs in your database via Lucid models

20 lines (19 loc) 779 B
import type { LucidRow } from '@adonisjs/lucid/types/model'; import type { SlugifyStrategyContract } from '../types.js'; /** * The DbIncrementStrategy creates unique slugs by querying the similar * existing slugs inside the database and appends a counter to them. * For example: If there is already a slug called "hello-world", then * another slug with the value will become "hello-world-1" and so on. */ export declare class DbIncrementStrategy implements SlugifyStrategyContract { #private; maxLengthBuffer: number; constructor(config: { separator?: string; }); /** * Converts an existing slug to a unique slug by inspecting the database */ makeSlugUnique(modelInstance: LucidRow, field: string, slug: string): Promise<string>; }