Skip to content

toniopelo/loopback-cascade-delete-mixin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status NSP Status

cascade-delete-mixin

This module is designed for the Strongloop Loopback framework. It provides cascade delete with a simple configuration on your models.

install

  npm install --save loopback-cascade-delete-mixin

mixinsources

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-cascade-delete-mixin",
      "../common/mixins"
    ]
  }
}

config

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

  {
    "name": "Product",
    "properties": {
      "name": {
        "type": "string",
      }
    },
    "relations": {
        "properties": {
          "type": "hasMany",
          "model": "Property",
          "foreignKey": ""
        }
     },
    "mixins": {
      "CascadeDelete": {
         "relations": ["properties", "description"]
       }
    }
  }

options

option type description required
relations [String] relations which you want to delete together with current model true

tests

Run the tests:

  npm test

Run with debugging output on:

  DEBUG='loopback:mixins:cascade-delete' npm test

About

Delete related models

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%