No description or website provided.
JavaScript
Latest commit ea6d1b3 Apr 15, 2016 Jonathan Casarrubias Release 1.0.2
Permalink
Failed to load latest commit information.
dist
src
test Release 1.0.0 Apr 14, 2016
.babelrc
.eslintrc Release 1.0.0 Apr 14, 2016
.gitignore
CHANGELOG.md
LICENSE.md Release 1.0.0 Apr 14, 2016
README.md
gulpfile.babel.js
package.json

README.md

NPM NPM

Loopback Stats Mixin

This module is designed for the Strongloop Loopback framework. It provides likes and dislikes functionallity to any Model.

INSTALL

  npm install loopback-likes-mixin --save

MIXINSOURCES

With loopback-boot@v2.8.0 mixinSources have been implemented in a way which allows for loading this mixin without changes to the server.js file previously required.

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

{
  "_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "../node_modules/loopback-likes-mixin/dist",
      "../common/mixins"
    ]
  }
}

STATS MIXIN

This mixin creates a Remote Method with endpoint entry /:id/like.

EXAMPLE

The following is the default configuration

"mixins": {
    "Likes": [
        {
          "method": "like",
          "endpoint": "/:id/like",
          "likes": "likes",
          "userModel": "User"
        }
    ]
}

is equivalent to

"mixins": {
    "Likes": true
}

The code defined above would create a localhost:3000/api/model/:id/likes endpoint with the ability to like and dislike an instance of a Model in which the mixin is implemented.

BOOT OPTIONS

The following options are the optional configurations for the mixin to work.

Options Type Requried Possible Values Examples
method String No Any like, likeThis, liker
endpoint String No URL Form /likes, /:id/likes
description String No Any Loopback Explorer Description
likes String No Any Model property name with Object type
userModel String No User based models User, Account, Admin.. e

LICENSE

MTI