lib/definitions/viewBuilder.js
function (evt, callback) {
    var self = this;

    function denorm() {
      if (self.executeDenormFnForEach) {
        return self.denormalizeForEach(evt, callback);
      }

      if (self.query) {
        return self.handleQuery(evt, self.query, callback);
      }

      if (!self.query && self.getQueryForThisViewBuilder) {
        self.getQueryForThisViewBuilder(evt, function (err, query) {
          if (err) {
            debug(err);
            return callback(err);
          }
          self.handleQuery(evt, query, callback);
        });
        return;
      }

      self.extractId(evt, function (err, id) {
        if (err) {
          debug(err);
          return callback(err);
        }

        self.loadViewModel(id, function (err, vm) {
          if (err) {
            debug(err);
            return callback(err);
          }

          if (vm.actionOnCommit === 'create' && !self.autoCreate) {
            return callback(null, []);
          }

          self.handleOne(vm, evt, function (err, notification) {
            if (err) {
              debug(err);
              return callback(err);
            }

            var notis = [];
            if (notification) {
              notis.push(notification);
            }

            callback(null, notis);
          });
        });
      });
    }

    // if (this.shouldHandleRequestsOnlyEvent) {
    this.shouldHandleEvent(evt, function (err, doHandle) {
      if (err) {
        return callback(err);
      }

      if (!doHandle) {
        return callback(null, []);
      }

      denorm();
    });
    // } else {
      // denorm();
    // }
  }
function (evt, callback) {
    var self = this;

    function denorm() {
      if (self.executeDenormFnForEach) {
        return self.denormalizeForEach(evt, callback);
      }

      if (self.query) {
        return self.handleQuery(evt, self.query, callback);
      }

      if (!self.query && self.getQueryForThisViewBuilder) {
        self.getQueryForThisViewBuilder(evt, function (err, query) {
          if (err) {
            debug(err);
            return callback(err);
          }
          self.handleQuery(evt, query, callback);
        });
        return;
      }

      self.extractId(evt, function (err, id) {
        if (err) {
          debug(err);
          return callback(err);
        }

        self.loadViewModel(id, function (err, vm) {
          if (err) {
            debug(err);
            return callback(err);
          }

          if (vm.actionOnCommit === 'create' && !self.autoCreate) {
            return callback(null, []);
          }

          self.handleOne(vm, evt, function (err, notification) {
            if (err) {
              debug(err);
              return callback(err);
            }

            var notis = [];
            if (notification) {
              notis.push(notification);
            }

            callback(null, notis);
          });
        });
      });
    }

    // if (this.shouldHandleRequestsOnlyEvent) {
    this.shouldHandleEvent(evt, function (err, doHandle) {
      if (err) {
        return callback(err);
      }

      if (!doHandle) {
        return callback(null, []);
      }

      denorm();
    });
    // } else {
      // denorm();
    // }
  }
function ( evt , callback ) { var self = this ; function denorm ( ) { if ( self . executeDenormFnForEach ) { return self . denormalizeForEach ( evt , callback ) ; } if ( self . query ) { return self . handleQuery ( evt , self . query , callback ) ; } if ( ! self . query && self . getQueryForThisViewBuilder ) { self . getQueryForThisViewBuilder ( evt , function ( err , query ) { if ( err ) { debug ( err ) ; return callback ( err ) ; } self . handleQuery ( evt , query , callback ) ; } ) ; return ; } self . extractId ( evt , function ( err , id ) { if ( err ) { debug ( err ) ; return callback ( err ) ; } self . loadViewModel ( id , function ( err , vm ) { if ( err ) { debug ( err ) ; return callback ( err ) ; } if ( vm . actionOnCommit === 'create' && ! self . autoCreate ) { return callback ( null , [ ] ) ; } self . handleOne ( vm , evt , function ( err , notification ) { if ( err ) { debug ( err ) ; return callback ( err ) ; } var notis = [ ] ; if ( notification ) { notis . push ( notification ) ; } callback ( null , notis ) ; } ) ; } ) ; } ) ; } // if (this.shouldHandleRequestsOnlyEvent) { this . shouldHandleEvent ( evt , function ( err , doHandle ) { if ( err ) { return callback ( err ) ; } if ( ! doHandle ) { return callback ( null , [ ] ) ; } denorm ( ) ; } ) ; // } else { // denorm(); // } }
Denormalizes an event.
@param {Object}   evt      The passed event.
@param {Function} callback The function, that will be called when this action is completed.
`function(err, notifications){}`
Denormalizes an event .