lib/eventstore.js
function(obj, callback) {
    if (obj.streamId && !obj.aggregateId) {
      obj.aggregateId = obj.streamId;
    }

    if (!obj.aggregateId) {
      var err = new Error('An aggregateId should be passed!');
      debug(err);
      if (callback) callback(err);
      return;
    }

    obj.streamId = obj.aggregateId;

    var self = this;

    async.waterfall([
        function getNewIdFromStorage(callback) {
          self.getNewId(callback);
        },
        function commit(id, callback) {
          try {
            var snap = new Snapshot(id, obj);
            snap.commitStamp = new Date();
          } catch (err) {
            return callback(err);
          }

          self.store.addSnapshot(snap, function(error) {
            if (self.options.maxSnapshotsCount) {
              self.store.cleanSnapshots(_.pick(obj, 'aggregateId', 'aggregate', 'context'), callback);
            } else {
              callback(error);
            }
          });
        }],
      callback
    );
  }
function(obj, callback) {
    if (obj.streamId && !obj.aggregateId) {
      obj.aggregateId = obj.streamId;
    }

    if (!obj.aggregateId) {
      var err = new Error('An aggregateId should be passed!');
      debug(err);
      if (callback) callback(err);
      return;
    }

    obj.streamId = obj.aggregateId;

    var self = this;

    async.waterfall([
        function getNewIdFromStorage(callback) {
          self.getNewId(callback);
        },
        function commit(id, callback) {
          try {
            var snap = new Snapshot(id, obj);
            snap.commitStamp = new Date();
          } catch (err) {
            return callback(err);
          }

          self.store.addSnapshot(snap, function(error) {
            if (self.options.maxSnapshotsCount) {
              self.store.cleanSnapshots(_.pick(obj, 'aggregateId', 'aggregate', 'context'), callback);
            } else {
              callback(error);
            }
          });
        }],
      callback
    );
  }
function ( obj , callback ) { if ( obj . streamId && ! obj . aggregateId ) { obj . aggregateId = obj . streamId ; } if ( ! obj . aggregateId ) { var err = new Error ( 'An aggregateId should be passed!' ) ; debug ( err ) ; if ( callback ) callback ( err ) ; return ; } obj . streamId = obj . aggregateId ; var self = this ; async . waterfall ( [ function getNewIdFromStorage ( callback ) { self . getNewId ( callback ) ; } , function commit ( id , callback ) { try { var snap = new Snapshot ( id , obj ) ; snap . commitStamp = new Date ( ) ; } catch ( err ) { return callback ( err ) ; } self . store . addSnapshot ( snap , function ( error ) { if ( self . options . maxSnapshotsCount ) { self . store . cleanSnapshots ( _ . pick ( obj , 'aggregateId' , 'aggregate' , 'context' ) , callback ) ; } else { callback ( error ) ; } } ) ; } ] , callback ) ; }
stores a new snapshot
@param {Object}   obj      the snapshot data
@param {Function} callback the function that will be called when this action has finished [optional]
stores a new snapshot