Socket
Socket
Sign inDemoInstall

mongoose-sluggable

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-sluggable - npm Package Compare versions

Comparing version 0.7.2 to 0.7.4

2

index.js

@@ -45,2 +45,4 @@ var generateSlug = require('slug');

value = array.join(separator);
} else if(Object.prototype.toString.call(source) == '[object Function]') {
value = source(this, separator);
} else {

@@ -47,0 +49,0 @@ throw new Error('Source can be an array or a string');

2

package.json
{
"name": "mongoose-sluggable",
"version": "0.7.2",
"version": "0.7.4",
"description": "Mongoose slug plugin",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -45,3 +45,3 @@ # mongoose-sluggable

| **unique** | Should slug be unique for this collection? *Default "false"*. |
| **source** | Name of fields that will be used to create slug. You can pass string or array of strings? *Default "title"*. |
| **source** | Name of fields that will be used to create slug. You can pass string, an array of strings or a function? *Default "title"*. |
| **separator** | Separator used to replace all non a-z and 0-9 characters. *Default "-"*. |

@@ -84,2 +84,21 @@ | **updatable** | If set to *"false"*, not empty slug will not be changed by the plugin. *Default "true"*. |

Now document with name "Dariusz" and surname "Półtorak" will be translated to "dariusz-poltorak". And another document like that will receive "dariusz-poltorak-2".
Example for source as function:
```
var slugSource = function(doc, seperator){
if(doc.role = 'COMPANY') {
return String(doc.title || '').trim();
}
else {
return String(doc.firstName + seperator + doc.lastName || '').trim();
}
};
schema.plugin(sluggable, {
"field": "username",
"source": slugSource,
"unique": true,
"updatable": false
});
```
Now document with name "Dariusz" and surname "Półtorak" will be translated to "dariusz-poltorak". And another document like that will receive "dariusz-poltorak-2".
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc