0.2.5 • Published 2 years ago
loopback-slug v0.2.5
loopback-slug
url friendly generator for loopback.io framework.
Installation
This module is installed via npm:
$ npm install loopback-slug
or
$ npm install git://github.com/rikhart/loopback-slug.git
Example Usage
Edit the /common/models/name_of_your_models.js and add a hook method. Use the hook "beforeSave" method to add the functionality, pass the Model,newdata,and the configoptions.
Configoptions:(json object)
- separator (Default: '-') - Separator to use for characters.
- slug (Default: 'slug') - Parts that are uploaded simultaneously.
- fields (Default: 'title') - Array that will use to form the slug.
- lowercase (Default: false) - Convert the slug to lowercase.
Works in last loopback Version, where currentInstance is part of the ctx.
var loopbackslug=require("loopback-slug");
module.exports = function (Category) {
Category.observe('before save', function (ctx, next) { //!!important
loopbackslug.middleware(Category, ctx, {
fields: ['name'],
slug: "slug"
}, function (err) {
if (err) return next(err);
else next(null);
});
});
};
License
Apache-2.0 © Dick Van Ocampo Davila
0.2.5
2 years ago
0.2.4
2 years ago
0.2.3
6 years ago
0.2.2
6 years ago
0.2.1
6 years ago
0.2.0
6 years ago
0.1.9
7 years ago
0.1.8
7 years ago
0.1.7
8 years ago
0.1.6
8 years ago
0.1.5
8 years ago
0.1.4
8 years ago
0.1.3
8 years ago
0.1.2
8 years ago
0.1.1
9 years ago
0.1.0
9 years ago
0.0.9
9 years ago
0.0.8
9 years ago
0.0.2
9 years ago
1.0.1
9 years ago
1.0.0
9 years ago