1.0.13 • Published 8 years ago

sails-linking-models v1.0.13

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

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
1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.0

8 years ago