1.2.6 • Published 10 years ago

mongoose-slug-unique v1.2.6

Weekly downloads
60
License
-
Repository
github
Last release
10 years ago

mongoose-slug-unique

a simple mongoose plugin that populates a Mongoose Schema with .slug wich is unique, from one or more existing properties, when the given prop is set.

installation

$ npm install mongoose-slug-unique

Usage

var slug = require('mongoose-slug-unique');

schema.plugin(slug('name'));
var Song = mongoose.model('Song', schema);

var song = new Song();
song.name = 'frank ab';
song.slug; // > frank-ab

To use different slug candidates pass them as array

var slug = require('mongoose-slug');

schema.plugin(slug(['firstName', 'lastName']));
var Person = mongoose.model('Person', schema);

var person = new Person({firstName: 'John', lastName: 'Doe'});

person.save(function(err, person) {
person.slug; // > john-doe	
});

License

MIT

1.2.6

10 years ago

1.2.5

10 years ago

1.2.3

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago