{"_id":"mongoose-slug-generator","_rev":"16-8ac81124c37bc46f0edd6d737bedfe98","name":"mongoose-slug-generator","time":{"modified":"2022-06-20T07:49:39.444Z","created":"2015-11-30T08:58:31.784Z","0.0.1":"2015-11-30T08:58:31.784Z","0.1.0":"2015-11-30T16:47:26.336Z","1.0.0":"2015-11-30T16:55:10.587Z","1.0.1":"2015-12-07T19:30:23.151Z","1.0.2":"2015-12-12T13:30:54.939Z","1.0.3":"2016-01-31T17:02:15.219Z","1.0.4":"2016-02-08T17:20:36.755Z"},"maintainers":[{"email":"jolorenzom@gmail.com","name":"jolorenzom"},{"email":"angel.quesada@kubide.es","name":"gelito"},{"email":"desarrollo@kubide.es","name":"dev.kubide"}],"dist-tags":{"latest":"1.0.4"},"description":"Mongoose plugin to create slugs and unique slugs in any field","readme":"# mongoose-slug-generator\n\nMongoose plugin for creating slugs based on mongoose schema fields. For example you can create a slug based on a document's title and author's name: _my-post-title-kevin-roosevelt_, or unique slugs based on just the title: _my-post-title-Nyiy4wW9l_.\n\n## Installation\n\nThe best way to install it is using **npm**\n\n```sh\nnpm install mongoose-slug-generator --save\n```\n\n## Loading\n\n```js\nvar slug = require('mongoose-slug-generator');\n```\n\n## Initialization\n\n```js\nvar mongoose = require('mongoose');\nmongoose.plugin(slug);\n```\n\n## Usage\n\nThis plugin is based on the idea of using the **mongoose schema** as the way to check the use of slug fields.\n\nThe plugin checks and updates automatically the *slug field* with the correct slug.\n\n### Basic Usage\n\nIf you only want to create the slug based on a simple field.\n\n```js\nvar mongoose = require('mongoose'),\n    slug = require('mongoose-slug-generator'),\n    mongoose.plugin(slug),\n    Schema = mongoose.Schema,\n    schema = new Schema({\n        title: String,\n        slug: { type: String, slug: \"title\" }\n});\n```\n\n\n### Multiple slug fields\n\nYou can add as many slug fields as you wish\n\n```js\nvar mongoose = require('mongoose'),\n    slug = require('mongoose-slug-generator'),\n    mongoose.plugin(slug),\n    Schema = mongoose.Schema,\n    schema = new Schema({\n        title: String,\n        subtitle: String,\n        slug: { type: String, slug: \"title\" },\n        slug2: { type: String, slug: \"title\" },\n        slug3: { type: String, slug: \"subtitle\" }\n});\n```\n\n\n### Multiple fields to create the slug\n\nIf you want, you can use more than one field in order to create a new slug field.\n\n```js\nvar mongoose = require('mongoose'),\n    slug = require('mongoose-slug-generator'),\n    mongoose.plugin(slug),\n    Schema = mongoose.Schema,\n    schema = new Schema({\n        title: String,\n        subtitle: String,\n        slug: { type: String, slug: [\"title\", \"subtitle\"] }\n});\n```\n\n\n### Unique slug field\n\nTo create a unique slug field, you must only add add the *unique: true* parameter in the path (also, this way the default mongo unique index gets created)\n\n```js\nvar mongoose = require('mongoose'),\n    slug = require('mongoose-slug-generator'),\n    mongoose.plugin(slug),\n    Schema = mongoose.Schema,\n    schema = new Schema({\n        title: String,\n        subtitle: String,\n        slug: { type: String, slug: [\"title\", \"subtitle\"], unique: true }\n});\n```\n\nIf _unique_ is set, the plugin searches in the mongo database, and if the slug already exists in the collection, it appends to the slug a separator (default: \"-\") and a random string (generated with the shortid module).\n\n**example random**\n\n```js\nmongoose.model('Resource').create({\n    title: 'Am I wrong, fallin\\' in love with you!',\n    subtitle: \"tell me am I wrong, well, fallin' in love with you\"\n}) // slug -> 'am-i-wrong-fallin-in-love-with-you'\n\nmongoose.model('Resource').create({\n    title: 'Am I wrong, fallin\\' in love with you!',\n    subtitle: \"tell me am I wrong, well, fallin' in love with you\"\n}) // slug -> 'am-i-wrong-fallin-in-love-with-you-Nyiy4wW9l'\n\nmongoose.model('Resource').create({\n    title: 'Am I wrong, fallin\\' in love with you!',\n    subtitle: \"tell me am I wrong, well, fallin' in love with you\"\n}) // slug -> 'am-i-wrong-fallin-in-love-with-you-NJeskEPb5e'\n```\n\nAlternatively you can modify this behaviour and instead of appending a random string, an incremental counter will be used. For that to happen, you must use the parameter *slug_padding_size* specifying the total length of the counter:  \n\n**example counter**\n\n```js\nvar mongoose = require('mongoose'),\n    slug = require('mongoose-slug-generator'),\n    mongoose.plugin(slug),\n    Schema = mongoose.Schema,\n    schema = new Schema({\n        title: String,\n        subtitle: String,\n        slug: { type: String, slug: [\"title\", \"subtitle\"], slug_padding_size: 4,  unique: true }\n});\n\nmongoose.model('Resource').create({\n    title: 'Am I wrong, fallin\\' in love with you!',\n    subtitle: \"tell me am I wrong, well, fallin' in love with you\"\n}) // slug -> 'am-i-wrong-fallin-in-love-with-you'\n\nmongoose.model('Resource').create({\n    title: 'Am I wrong, fallin\\' in love with you!',\n    subtitle: \"tell me am I wrong, well, fallin' in love with you\"\n}) // slug -> 'am-i-wrong-fallin-in-love-with-you-0001'\n\nmongoose.model('Resource').create({\n    title: 'Am I wrong, fallin\\' in love with you!',\n    subtitle: \"tell me am I wrong, well, fallin' in love with you\"\n}) // slug -> 'am-i-wrong-fallin-in-love-with-you-0002'\n```\n\n\n### Choose your own options\n\nYou can change any options adding to the plugin\n\n```js\nvar mongoose = require('mongoose'),\n    slug = require('mongoose-slug-generator'),\n    options = {\n        separator: \"-\",\n        lang: \"en\",\n        truncate: 120\n    },\n    mongoose.plugin(slug, options),\n    Schema = mongoose.Schema,\n    schema = new Schema({\n        title: String,\n        subtitle: String,\n        slug: { type: String, slug: [\"title\", \"subtitle\"], unique: true }\n});\n```\n\nYou can find more options in the [speakingURL's npm page](https://www.npmjs.com/package/speakingurl)\n\n## Support\n\nThis plugin is proudly supported by [Kubide](http://kubide.es/)\n\n","versions":{"1.0.0":{"name":"mongoose-slug-generator","version":"1.0.0","description":"Mongoose plugin to create slugs and unique slugs in any field","main":"index.js","directories":{"lib":"./lib"},"scripts":{"prepublish":"npm run test","test":"mocha --reporter spec"},"repository":{"type":"git","url":"git+https://github.com/Kubide/mongoose-slug-generator.git"},"keywords":["slug","url","permalink","slugify","seo","mongoose","generator","unique","seo friendly url","user friendly url","nice looking url","pretty url","clean url","static url","nice url"],"author":{"name":"Kubide","email":"hola@kubide.es","url":"http://kubide.es"},"contributors":[{"name":"Ángel Luis Quesada","email":"angel.quesada@kubide.es","url":"http://gelito.me"}],"license":"MIT","bugs":{"url":"https://github.com/Kubide/mongoose-slug-generator/issues"},"homepage":"https://github.com/Kubide/mongoose-slug-generator#readme","engines":{"node":">= 0.12.7"},"dependencies":{"async":"^1.5.0","speakingurl":"^7.0.0"},"devDependencies":{"chai":"^3.3.0","mocha":"^2.3.3","mongoose":"4.*","nodemon":"^1.7.1","supertest":"^1.1.0"},"gitHead":"498df54bad6b554a8ab8234671eb495180a55c4d","_id":"mongoose-slug-generator@1.0.0","_shasum":"ce92fa2a91c15413f5860c977ecd3a6c27d3757d","_from":".","_npmVersion":"2.14.4","_nodeVersion":"4.1.1","_npmUser":{"name":"kubide","email":"hola@kubide.es"},"dist":{"shasum":"ce92fa2a91c15413f5860c977ecd3a6c27d3757d","tarball":"https://registry.npmjs.org/mongoose-slug-generator/-/mongoose-slug-generator-1.0.0.tgz","integrity":"sha512-ZDoMZ8E4bcnpd2wTqbVF7y/wgF71xzVtM9todEJu31WdsZFvjV76axwIa/GxbtXuatCj1hfsKP2eHmR3bS364w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDWkfAvNmpeMwG+TsKhZWuP7pORKptUtLBnU+LDCopFFAiAyoYWCGrmH+TNwgT5RC6HTdYAMqREJNBV2/ETUFysd5Q=="}]},"maintainers":[{"name":"kubide","email":"hola@kubide.es"}]},"1.0.1":{"name":"mongoose-slug-generator","version":"1.0.1","description":"Mongoose plugin to create slugs and unique slugs in any field","main":"index.js","directories":{"lib":"./lib"},"scripts":{"prepublish":"npm run test","test":"mocha --reporter spec"},"repository":{"type":"git","url":"git+https://github.com/Kubide/mongoose-slug-generator.git"},"keywords":["slug","url","permalink","slugify","seo","mongoose","generator","unique","seo friendly url","user friendly url","nice looking url","pretty url","clean url","static url","nice url"],"author":{"name":"Kubide","email":"hola@kubide.es","url":"http://kubide.es"},"contributors":[{"name":"Ángel Luis Quesada","email":"angel.quesada@kubide.es","url":"http://gelito.me"}],"license":"MIT","bugs":{"url":"https://github.com/Kubide/mongoose-slug-generator/issues"},"homepage":"https://github.com/Kubide/mongoose-slug-generator#readme","engines":{"node":">= 0.12.7"},"dependencies":{"async":"^1.5.0","speakingurl":"^7.0.0"},"devDependencies":{"chai":"^3.3.0","mocha":"^2.3.3","mongoose":"4.*","nodemon":"^1.7.1","supertest":"^1.1.0"},"gitHead":"3534fbcaa0eb42baa90b98af4c7a40ade63b486d","_id":"mongoose-slug-generator@1.0.1","_shasum":"80772c6f628f56d0699b677c67087db391d768ec","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.7","_npmUser":{"name":"kubide","email":"hola@kubide.es"},"dist":{"shasum":"80772c6f628f56d0699b677c67087db391d768ec","tarball":"https://registry.npmjs.org/mongoose-slug-generator/-/mongoose-slug-generator-1.0.1.tgz","integrity":"sha512-LaiMtKU3ZjzlAryTaAnvLoD1GT4O0S/m3b/irbgkAgMQaO6YbEekPo7aWWY2LQjugOqyTxxVHhcImFCmQa/ARA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB/+0GXZsAV/ciYSNYXfV7fAsbsXFMpKfuBm4GIvYluyAiEA7SX30Z/K9mJHC2c0BVDsIRyeuwnS0clgGhoVAdO+998="}]},"maintainers":[{"name":"gelito","email":"angel.quesada@kubide.es"},{"name":"kubide","email":"hola@kubide.es"}]},"1.0.2":{"name":"mongoose-slug-generator","version":"1.0.2","description":"Mongoose plugin to create slugs and unique slugs in any field","main":"index.js","directories":{"lib":"./lib"},"scripts":{"prepublish":"npm run test","test":"mocha --reporter spec"},"repository":{"type":"git","url":"git+https://github.com/Kubide/mongoose-slug-generator.git"},"keywords":["slug","url","permalink","slugify","seo","mongoose","generator","unique","seo friendly url","user friendly url","nice looking url","pretty url","clean url","static url","nice url"],"author":{"name":"Kubide","email":"hola@kubide.es","url":"http://kubide.es"},"contributors":[{"name":"Ángel Luis Quesada","email":"angel.quesada@kubide.es","url":"http://gelito.me"}],"license":"MIT","bugs":{"url":"https://github.com/Kubide/mongoose-slug-generator/issues"},"homepage":"https://github.com/Kubide/mongoose-slug-generator#readme","engines":{"node":">= 0.12.7"},"dependencies":{"async":"^1.5.0","speakingurl":"^7.0.0"},"devDependencies":{"chai":"^3.3.0","mocha":"^2.3.3","mongoose":"4.*","nodemon":"^1.7.1","supertest":"^1.1.0"},"gitHead":"0048fa031eed3f2f83967a48bebe3a735aa811cd","_id":"mongoose-slug-generator@1.0.2","_shasum":"0c0fecdab9cbcdf490e5315e9010cc67c9cd1be9","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.7","_npmUser":{"name":"kubide","email":"hola@kubide.es"},"dist":{"shasum":"0c0fecdab9cbcdf490e5315e9010cc67c9cd1be9","tarball":"https://registry.npmjs.org/mongoose-slug-generator/-/mongoose-slug-generator-1.0.2.tgz","integrity":"sha512-/w2kSU0oDslo0VmVRMNY+P6LL29UL4bUgmNX37+fQ4a8KKS1EuGWixTEvhlodl2k8j8w5/4t1k8lkOd4aB1m0w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQChDK2+HUDhxRVq9s/u9MQiBuLRPj2JS1R0MWxxIydrQQIhAOBxrfyBoZlDyejYtmEhH1aNf190kdVomOImIkPils5J"}]},"maintainers":[{"name":"gelito","email":"angel.quesada@kubide.es"},{"name":"kubide","email":"hola@kubide.es"}]},"1.0.3":{"name":"mongoose-slug-generator","version":"1.0.3","description":"Mongoose plugin to create slugs and unique slugs in any field","main":"index.js","directories":{"lib":"./lib"},"scripts":{"prepublish":"npm run test","test":"mocha --reporter spec"},"repository":{"type":"git","url":"git+https://github.com/Kubide/mongoose-slug-generator.git"},"keywords":["slug","url","permalink","slugify","seo","mongoose","generator","unique","seo friendly url","user friendly url","nice looking url","pretty url","clean url","static url","nice url"],"author":{"name":"Kubide","email":"hola@kubide.es","url":"http://kubide.es"},"contributors":[{"name":"Ángel Luis Quesada","email":"angel.quesada@kubide.es","url":"http://gelito.me"},{"name":"Eneko Lakasta","email":"eneko.lakasta@kubide.es"}],"license":"MIT","bugs":{"url":"https://github.com/Kubide/mongoose-slug-generator/issues"},"homepage":"https://github.com/Kubide/mongoose-slug-generator#readme","engines":{"node":">= 0.12.7"},"dependencies":{"async":"^1.5.0","speakingurl":"^7.0.0"},"devDependencies":{"chai":"^3.3.0","mocha":"^2.3.3","mongoose":"4.*","nodemon":"^1.7.1","supertest":"^1.1.0"},"gitHead":"e7db51ea90a0275fa5c7f95307f5a8b037183c63","_id":"mongoose-slug-generator@1.0.3","_shasum":"d9ab996f0d84837f21ec3de51f51b97ab2c56d5a","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.7","_npmUser":{"name":"kubide","email":"hola@kubide.es"},"dist":{"shasum":"d9ab996f0d84837f21ec3de51f51b97ab2c56d5a","tarball":"https://registry.npmjs.org/mongoose-slug-generator/-/mongoose-slug-generator-1.0.3.tgz","integrity":"sha512-cByOnA6JIdww+LpTAN+8wdAmc2R591cO9zWyQEwL3HcMYJKgGgCONiLJOuCwq2P2HWpOEOywWruw1qyz58DSOw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG++0RMFFBmz3B1Q6SaOI1UE1fz3AucA1Yh7+awoSNk3AiB1rV/T3uis9DJ2l/ub0FEoqRML9kef2r4tNzYx/Ukwhw=="}]},"maintainers":[{"name":"gelito","email":"angel.quesada@kubide.es"},{"name":"kubide","email":"hola@kubide.es"}]},"1.0.4":{"name":"mongoose-slug-generator","version":"1.0.4","description":"Mongoose plugin to create slugs and unique slugs in any field","main":"index.js","directories":{"lib":"./lib"},"scripts":{"prepublish":"npm run test","test":"mocha --reporter spec"},"repository":{"type":"git","url":"git+https://github.com/Kubide/mongoose-slug-generator.git"},"keywords":["slug","url","permalink","slugify","seo","mongoose","generator","unique","seo friendly url","user friendly url","nice looking url","pretty url","clean url","static url","nice url"],"author":{"name":"Kubide","email":"hola@kubide.es","url":"http://kubide.es"},"contributors":[{"name":"Ángel Luis Quesada","email":"angel.quesada@kubide.es","url":"http://gelito.me"},{"name":"Eneko Lakasta","email":"eneko.lakasta@kubide.es"}],"license":"MIT","bugs":{"url":"https://github.com/Kubide/mongoose-slug-generator/issues"},"homepage":"https://github.com/Kubide/mongoose-slug-generator#readme","engines":{"node":">= 0.12.7"},"dependencies":{"async":"^1.5.0","shortid":"^2.2.4","speakingurl":"^7.0.0"},"devDependencies":{"chai":"^3.3.0","mocha":"^2.3.3","mongoose":"4.*","nodemon":"^1.7.1","supertest":"^1.1.0"},"gitHead":"843a006b1e9ec8ebf7591fbe5238308d788c97f3","_id":"mongoose-slug-generator@1.0.4","_shasum":"a5364f2d4203783472c235c302d35aa1b20d53eb","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.7","_npmUser":{"name":"kubide","email":"hola@kubide.es"},"dist":{"shasum":"a5364f2d4203783472c235c302d35aa1b20d53eb","tarball":"https://registry.npmjs.org/mongoose-slug-generator/-/mongoose-slug-generator-1.0.4.tgz","integrity":"sha512-YTluRZROhrHgcncstJTJsxT4K6xR2xIGtF9a0uf4Z1mNFADBVoyanezdKgjQBxN2zfB8PH6wpU8mh4AFxL4+4w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCWGLKJTpySJeHbIBdlNyKpGQo7Fn+x4/7g54+tQPFW/wIhAO80c75+ISVmo9yrJA93l/YglEWZfz2nZ2JRhpKl/pZ6"}]},"maintainers":[{"name":"gelito","email":"angel.quesada@kubide.es"},{"name":"kubide","email":"hola@kubide.es"}],"_npmOperationalInternal":{"host":"packages-9-west.internal.npmjs.com","tmp":"tmp/mongoose-slug-generator-1.0.4.tgz_1454952033994_0.9791615097783506"}}},"homepage":"https://github.com/Kubide/mongoose-slug-generator#readme","keywords":["slug","url","permalink","slugify","seo","mongoose","generator","unique","seo friendly url","user friendly url","nice looking url","pretty url","clean url","static url","nice url"],"repository":{"type":"git","url":"git+https://github.com/Kubide/mongoose-slug-generator.git"},"contributors":[{"name":"Ángel Luis Quesada","email":"angel.quesada@kubide.es","url":"http://gelito.me"},{"name":"Eneko Lakasta","email":"eneko.lakasta@kubide.es"}],"author":{"name":"Kubide","email":"hola@kubide.es","url":"http://kubide.es"},"bugs":{"url":"https://github.com/Kubide/mongoose-slug-generator/issues"},"license":"MIT","readmeFilename":"README.md","users":{"igorissen":true}}