lib/pm.js
function (date, callback) {
    var self = this;

    this.sagaStore.getOlderSagas(date, function (err, sagas) {
      if (err) {
        debug(err);
        return callback(err);
      }
      var sagaModels = [];
      sagas.forEach(function (s) {
        var sagaModel = new SagaModel(s.id);
        sagaModel.set(s);
        sagaModel.actionOnCommit = 'update';
        var calledRemoveTimeout = false;
        var orgRemoveTimeout = sagaModel.removeTimeout;
        sagaModel.removeTimeout = function () {
          calledRemoveTimeout = true;
          orgRemoveTimeout.bind(sagaModel)();
        };
        sagaModel.commit = function (clb) {
          if (sagaModel.isDestroyed()) {
            self.removeSaga(sagaModel, clb);
          } else if (calledRemoveTimeout) {
            sagaModel.setCommitStamp(new Date());
            self.sagaStore.save(sagaModel.toJSON(), [], clb);
          } else {
            var err = new Error('Use commit only to remove a saga!');
            debug(err);
            if (clb) { return clb(err); }
            throw err;
          }
        };
        sagaModels.push(sagaModel);
      });

      callback(null, sagaModels);
    });
  }
function (date, callback) {
    var self = this;

    this.sagaStore.getOlderSagas(date, function (err, sagas) {
      if (err) {
        debug(err);
        return callback(err);
      }
      var sagaModels = [];
      sagas.forEach(function (s) {
        var sagaModel = new SagaModel(s.id);
        sagaModel.set(s);
        sagaModel.actionOnCommit = 'update';
        var calledRemoveTimeout = false;
        var orgRemoveTimeout = sagaModel.removeTimeout;
        sagaModel.removeTimeout = function () {
          calledRemoveTimeout = true;
          orgRemoveTimeout.bind(sagaModel)();
        };
        sagaModel.commit = function (clb) {
          if (sagaModel.isDestroyed()) {
            self.removeSaga(sagaModel, clb);
          } else if (calledRemoveTimeout) {
            sagaModel.setCommitStamp(new Date());
            self.sagaStore.save(sagaModel.toJSON(), [], clb);
          } else {
            var err = new Error('Use commit only to remove a saga!');
            debug(err);
            if (clb) { return clb(err); }
            throw err;
          }
        };
        sagaModels.push(sagaModel);
      });

      callback(null, sagaModels);
    });
  }
function ( date , callback ) { var self = this ; this . sagaStore . getOlderSagas ( date , function ( err , sagas ) { if ( err ) { debug ( err ) ; return callback ( err ) ; } var sagaModels = [ ] ; sagas . forEach ( function ( s ) { var sagaModel = new SagaModel ( s . id ) ; sagaModel . set ( s ) ; sagaModel . actionOnCommit = 'update' ; var calledRemoveTimeout = false ; var orgRemoveTimeout = sagaModel . removeTimeout ; sagaModel . removeTimeout = function ( ) { calledRemoveTimeout = true ; orgRemoveTimeout . bind ( sagaModel ) ( ) ; } ; sagaModel . commit = function ( clb ) { if ( sagaModel . isDestroyed ( ) ) { self . removeSaga ( sagaModel , clb ) ; } else if ( calledRemoveTimeout ) { sagaModel . setCommitStamp ( new Date ( ) ) ; self . sagaStore . save ( sagaModel . toJSON ( ) , [ ] , clb ) ; } else { var err = new Error ( 'Use commit only to remove a saga!' ) ; debug ( err ) ; if ( clb ) { return clb ( err ) ; } throw err ; } } ; sagaModels . push ( sagaModel ) ; } ) ; callback ( null , sagaModels ) ; } ) ; }
Use this function to get all sagas that are older then the passed date.
@param {Date}     date     The date
@param {Function} callback The function, that will be called when this action is completed.
`function(err, sagas){}` saga is of type Array.
Use this function to get all sagas that are older then the passed date .