Socket
Socket
Sign inDemoInstall

@loudsrl/loopback-cascade-delete-mixin

Package Overview
Dependencies
5
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @loudsrl/loopback-cascade-delete-mixin

Loopback cascade delete mixin


Version published
Maintainers
2
Install size
2.32 MB
Created

Readme

Source

Build Status NSP Status

cascade-delete-mixin

Greenkeeper badge

IMPORTANT! Mixin object structure is changed. If you use "relationsConfig" key, please use 1.3.1 version
npm install --save loopback-cascade-delete-mixin@1.3.1 
or change object structure! (see below)

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

Node.js v. > 6

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": ""
        },
        "description": {
           "type": "hasMany",
           "model": "Property",
           "foreignKey": ""
         }
     },
    "mixins": {
      "CascadeDelete": {
        "relations": 
        ["properties",
        {"name": "description", "deepDelete": false}],
        "deepDelete": true,
      }
    }
  }

options

optiontypedescriptionrequired
relations[String] or [Object]relations which you want to delete together with current model, see object keys belowtrue
deepDelete[Boolean]enable or disable the deep delete function. If activated, the CascadeDelete will be executed on the deleted related models as well (if they have the CascadeDelete mixin specified). If not used, disable it for performance mattersfalse

relations object

keytypedescriptionrequired
name[String]relation nametrue
deepDelete[Boolean]enable or disable the deep delete function for current relation. If activated, the CascadeDelete will be executed on the deleted related models as well (if they have the CascadeDelete mixin specified). If not used, disable it for performance mattersfalse
foreignKey[String]custom foreign keyfalse

tests

Run the tests:

  npm test

Run with debugging output on:

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

Keywords

FAQs

Last updated on 15 Apr 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc