Пример #1
0
 public static final function rollback()
 {
     if (0 === Kit::len(self::$history)) {
         return FALSE;
     }
     foreach (Kit::reversed(self::$history) as $operation) {
         if (self::OP_INSERT === $operation['Type']) {
             $operation['Collection']->deleteTheOnlyOne(['_id' => $operation['Id']], TRUE);
         } elseif (self::OP_UPDATE === $operation['Type']) {
             $operation['Collection']->updateTheOnlyOne(['_id' => $operation['Document']['_id']], $operation['Document'], TRUE);
         } elseif (self::OP_REMOVE === $operation['Type']) {
             $operation['Collection']->addOne($operation['Document'], TRUE);
         }
     }
     self::$isChanged = FALSE;
     return TRUE;
 }