Novelty Polygonal Mathematics

    sails-linking-models

    1.0.13 • Public • Published

    sails-linking-models

    Build Coverage Quality Dependencies

    Description

    Ability to generate hateoas-compatible links to actions (read/update/delete) on model items.

    Install

    $ npm install sails-linking-models

    Usage

    Mixin with your sails model declarations (in /api/models/YOUR_MODEL.js) like so:

       var linkingModels = require('sails-linking-models');
       var model = {
          // Your model declaration here
          };
       module.exports = linkingModels.mixin(model);

    Inside your model declaration you can generate links by passing in a controller name and the reverseRouteService function, and, optionally, an array of controller actions to link to:

       var actions =  ['action1', 'action2']; 
       var links = this.modelLinks(controllerName, reverseRouteService, actions);

    Actions will default to the blueprint actions if none is passed in:

       ['findOne', 'update', 'destroy']

    Tests

    $ npm install
    $ npm test

    Install

    npm i sails-linking-models

    DownloadsWeekly Downloads

    17

    Version

    1.0.13

    License

    MIT

    Last publish

    Collaborators

    • chrisns
    • ollienilsen