1.3.1 • Published 10 years ago

mongoose-slug v1.3.1

Weekly downloads
62
License
-
Repository
-
Last release
10 years ago

mongoose-slug

a simple mongoose plugin that populates .slug when the given prop is set.

installation

$ npm install mongoose-slug

Usage

var slug = require('mongoose-slug');
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.3.1

10 years ago

1.3.0

10 years ago

1.2.0

11 years ago

1.1.1

11 years ago

1.1.0

11 years ago

1.0.0

11 years ago

0.0.1

11 years ago