New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bookshelf-deep-changed-plugin

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bookshelf-deep-changed-plugin

Allows bookshelf models to check whether a value you save is different than the existing value in the database.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

bookshelf-deep-changed-plugin

NPM Version Build Status Test Coverage Dependencies devDependencies JavaScript Style Guide

Allows bookshelf models to check whether a value you save is different than the existing value in the database.

Installation:
$ npm install --save bookshelf-deep-changed-plugin

Usage:

module.exports = Repository.Model.extend({
  tableName: 'users',
  initialize: function () {
    this.on('updating', function (model, attrs, options) {
      return this
        .deepChanged('name', 'email', options)
        .then(function (hasDeepChanged) {
          if (hasDeepChanged[0]) {
            this.set('name_changed_at', new Date());
          }
          if (hasDeepChanged[1]) {
            this.set('email_changed_at', new Date());
          }
        });
    });
  }
});

Do not forget to add bookshelf-deep-changed-plugin to the list of bookshelf's plugins when you require bookshelf:

const knex = require('knex')({
    /// knex initialization
  })
const bookshelf = require('bookshelf')(knex);

bookshelf.plugin(require('bookshelf-deep-changed-plugin'));

License

MIT

Author

Oron Nadiv (oron@nadiv.us)

Keywords

FAQs

Package last updated on 02 Jul 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc