/** * drop instance * * @param ConfigEntity $config 현재 설정 되어 있는 config * @param int $fetchCount fetch count * @return void */ public function remove(ConfigEntity $config, $fetchCount = 10) { $this->repo->connection()->beginTransaction(); $this->repo->dropDivisionTable($config); $this->configHandler->remove($config); // division table 은 drop 했으므로 처리하지 않는다. $config->set('division', false); while ($docs = $this->repo->fetch(['instanceId' => $config->get('instanceId')], null, $config, $fetchCount)) { foreach ($docs as $doc) { $this->repo->delete(new DocumentEntity($doc), $config); } } $this->repo->connection()->commit(); }
/** * get document list * * @param array $wheres make where query list * @param array $orders make order query list * @param int $limit number of list * @return DocumentEntity[] */ public function gets(array $wheres, array $orders, $limit = null) { $config = null; if (isset($wheres['instanceId'])) { $config = $this->configHandler->get($wheres['instanceId']); } $docs = $this->repo->fetch($wheres, $orders, $config, $limit); foreach ($docs as $key => $row) { $docs[$key] = new DocumentEntity($row); } return $docs; }