@palmabit/loopback-ds-slugify-mixin
A mixin to generate slug for loopback Models
Last updated a year ago by eliardo .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @palmabit/loopback-ds-slugify-mixin 
SYNC missed versions from official npm registry.

loopback-ds-slugify-mixin

Install

  npm i @palmabit/loopback-ds-slugify-mixin --save

Server Config

Add the mixins property to your server/model-config.json:

{
  "_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "../node_modules/@palmabit/loopback-ds-slugify-mixin",
      "../common/mixins"
    ]
  }
}

Model Config

To use with your Models add the mixins attribute to the definition object of your model config.

  {
    "name": "Widget",
    "properties": {
      "name": {
        "type": "string",
      }
    },
    "mixins": {
    "Slugify": {
      "slugifyOptions": { 
        "replacement": "=",
        "remove": null,
        "lower": true,
        "suffixTimestamp": true
      },
      "slugifiedField": "slug",
      "fieldToSlugify": "name"
    }
  }
  }
  • slugifyOptions: Optional. See https://github.com/simov/slugify for more infos
  • slugifiedField: [String] Optional. Default is "slug". Support dot notation (ex. "foo.bar") for nested
  • fieldToSlugify: [String] Required. Support dot notation (ex. "foo.bar") for nested
  • suffixTimestamp: [Boolean] Optional

Changelog

Changelog File

License

The MIT License (MIT). Please see License File for more information.

Current Tags

  • 1.1.1                                ...           latest (a year ago)

4 Versions

  • 1.1.1                                ...           a year ago
  • 1.1.0                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 1
Last Month 4
Dependencies (2)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |