Nostalgic Perogi Monogramming

    bookshelf-deep-changed

    1.0.0 • Public • Published

    Dependencies devDependency Status Build Status

    bookshelf-deep-changed

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

    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());
              }
            });
        });
      }
    });
    
    

    You need to add bookshelf-deep-changed to the list of bookshelf's plugins when you require bookshelf:

    var knex = require('knex')({
        /// knex initialization
      }),
      bookshelf = require('bookshelf')(knex);
    
    bookshelf.plugin(require('bookshelf-deep-changed'));
    

    Install

    npm i bookshelf-deep-changed

    DownloadsWeekly Downloads

    11

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • jyothis-qb
    • qburst-pratyush
    • cdrohithmqb
    • arunks_qburst
    • sudheeshqburst
    • davoodul
    • athul-qburst
    • mable-liza-mathew
    • sowmyab
    • anoop-kuttikkattu
    • munisa
    • dheerajds
    • arjunqb
    • ashishqburst
    • lanetix-system
    • manu-kodiyan-winmore
    • dnm-winmore
    • mkdyanugk
    • vigneshk7
    • soumyaarun
    • aswanth
    • sajith.qb
    • dhiluraj-qburst
    • anandqb
    • arun-dtk
    • vikasqb
    • acpradosh1234