{"id":14975612,"url":"https://github.com/sayburgh-solutions/mongoose-simple-slugify","last_synced_at":"2025-10-27T14:30:37.308Z","repository":{"id":48684090,"uuid":"319971385","full_name":"sayburgh-solutions/mongoose-simple-slugify","owner":"sayburgh-solutions","description":"A simple language agnostic mongoose plug-in for generating unique slugs from a given string.","archived":false,"fork":false,"pushed_at":"2021-08-04T10:34:27.000Z","size":302,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T06:05:58.441Z","etag":null,"topics":["mongoose","mongoose-plugin","slugify"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sayburgh-solutions.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-09T13:52:18.000Z","updated_at":"2022-08-19T22:50:16.000Z","dependencies_parsed_at":"2022-08-31T18:11:56.819Z","dependency_job_id":null,"html_url":"https://github.com/sayburgh-solutions/mongoose-simple-slugify","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayburgh-solutions%2Fmongoose-simple-slugify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayburgh-solutions%2Fmongoose-simple-slugify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayburgh-solutions%2Fmongoose-simple-slugify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayburgh-solutions%2Fmongoose-simple-slugify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sayburgh-solutions","download_url":"https://codeload.github.com/sayburgh-solutions/mongoose-simple-slugify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238508502,"owners_count":19484141,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mongoose","mongoose-plugin","slugify"],"created_at":"2024-09-24T13:52:17.138Z","updated_at":"2025-10-27T14:30:31.995Z","avatar_url":"https://github.com/sayburgh-solutions.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mongoose-simple-slugify ![npm](https://img.shields.io/npm/v/mongoose-simple-slugify) ![npm](https://img.shields.io/npm/dw/mongoose-simple-slugify)\n\nA simple language agnostic `mongoose` plugin for generating unique slugs from a given string.\n\n## Installation\nInstallation is as simple as any other `npm` package:\n\n```\n$ npm install mongoose-simple-slugify\n```\n\n## Usage\nGiven you have a schema in a file `models/post.js` that has a `title` and you want to generate a slug using that `title`, the corresponding code will be as follows:\n\n```js\n// models/post.js\n\n// regular mongoose stuff\nconst mongoose = require('mongoose');\nconst { Schema } = mongoose;\n\n// require mongoose-simple-slugify in your schema\nconst slugify = require('mongoose-simple-slugify');\n\nconst Post = mongoose.model(\n  'Post',\n  new Schema(\n    {\n      // title of the post\n      title: {\n        type: String,\n        required: true,\n      },\n      // slug generated for the post\n      slug: {\n        source: 'title', // source for generating the slug\n        type: String,\n        unique: true,\n      },\n\n      body: {\n        type: String,\n        required: true,\n      },\n    },\n\n    { timestamps: true },\n  ).plugin(slugify), // registering the plugin\n);\n\nmodule.exports = Post;\n\n```\n\nThat's all you need. Now everytime you create a new post a slug will be generated automatically. In case the generated slug is already in the database, a cryptographically correct random string will be appended to the slug.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayburgh-solutions%2Fmongoose-simple-slugify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsayburgh-solutions%2Fmongoose-simple-slugify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayburgh-solutions%2Fmongoose-simple-slugify/lists"}