1.2.1 • Published 7 years ago

loopback-ds-cascade-update-mixin v1.2.1

Weekly downloads
36
License
MIT
Repository
github
Last release
7 years ago

CASCADE UPDATE MIXIN

Greenkeeper badge

CircleCI Dependencies Coverage Status

This module is designed for the Strongloop Loopback framework. It provides cascade update functionality with a simple configuration on your models. This can be used to keep property values synchronised across related models.

INSTALL

  npm install --save loopback-ds-cascade-update-mixin

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/loopback-ds-cascade-update-mixin/lib",
      "../common/mixins"
    ]
  }
}

CONFIG

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

The config keys are the property names that you want to cascade.

The config values are an array of relationships that the property updates should cascade to.

  {
    "name": "Product",
    "properties": {
      "name": {
        "type": "string",
      }
    },
    "relations": {
        "relation1": {
          "type": "hasMany",
          "model": "Property",
          "foreignKey": ""
        }
     },
    "mixins": {
      "CascadeUpdate": {
         "status": [ "relation1", "relation2" ],
         "isTest": [ "relation1", "relation2" "relation3" ]
       }
    }
  }

TESTING

Run the tests in test.js

  npm test

DEBUGGING

Run with debugging output on:

  DEBUG='loopback:mixins:cascade-update' npm test
1.2.1

7 years ago

1.2.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago