@aliatech/loopback-diff-mixin

0.11.0 • Public • Published

Loopback Diff mixin

Build Status Coverage Status npm version

Loopback diff mixin allows to detect and hook for specific changes in persist models

Highlights

  • //TODO

IMPORTANT: This Loopback mixin has only be tested with Loopback 3 and MongoDB connector. Requires Node ≥ 8

This project is under development.

How to install

Install the package through NPM

npm i -S @aliatech/loopback-diff-mixin

Install the package through Yarn

yarn add --prod @aliatech/loopback-diff-mixin

Basic configuration

Include the mixin in server/model-config.json. Example for Loopback 3:

{
  "_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "../node_modules/@aliatech/loopback-diff-mixin/lib",
      "../common/mixins"
    ]
  }
}

Enable the mixin in your model definition, ie person.json.

{
  "name": "Person",
  "properties": {
    "name": "string"
  },
  "mixins": {
    "Diff": {
      "hooks": {
        "email": "emailChanged"
      }
    }
  }
}

Usage

//TODO

Debug

Prepend DEBUG environment when running server or tests to display what is happening:

DEBUG=loopback:mixins:diff node . # Run server with debug

Testing

Install develop dependences

npm i -D # If you use NPM
yarn install # If you use Yarn

Execute tests

npm test # Without coverage check
npm run test-with-coverage # With coverage check
DEBUG=loopback:mixins:diff npm test # With debug

Credits

Developed by Juan Costa for ALIA Technologies

ALIA Technologies

Package Sidebar

Install

npm i @aliatech/loopback-diff-mixin

Weekly Downloads

1

Version

0.11.0

License

MIT

Unpacked Size

41.9 kB

Total Files

21

Last publish

Collaborators

  • akeri