/** * Remove user. * * @param string $id * @return Response * @throws \Everyman\Neo4j\Exception * @throws \Exception */ public function removeUser($id) { $user = $this->_neo4j->getClient()->getNode($id); if (is_null($user)) { return new Response("Unable to delete because the user does not exist.", Response::HTTP_BAD_REQUEST); } try { $user->delete(); return new Response(['id' => $id], Response::HTTP_OK); } catch (\Exception $e) { return new Response($e->getMessage(), Response::HTTP_BAD_REQUEST); } }
/** * Remove all relations and nodes. * * @return \Everyman\Neo4j\Node * @throws \Everyman\Neo4j\Exception * @throws \Exception */ private function _flushDatabase() { $queryTemplate = "MATCH ()-[relation]->() RETURN relation"; $rows = $this->_neo4j->query($queryTemplate); foreach ($rows as $row) { $item = $this->_neo4j->getClient()->getRelationship($row['relation']->getId()); $this->_neo4j->getClient()->deleteRelationship($item); } $queryTemplate = "MATCH (node) RETURN node"; $rows = $this->_neo4j->query($queryTemplate); foreach ($rows as $row) { $node = $this->_neo4j->getClient()->getNode($row['node']->getId()); $this->_neo4j->getClient()->deleteNode($node); } return $node; }
/** * Get node by id. * * @param $id * @return \Everyman\Neo4j\Node * @throws \Everyman\Neo4j\Exception */ public function getNodeById($id) { return $this->_neo4j->getClient()->getNode($id); }
/** * @param integer $id * @return \Everyman\Neo4j\Relationship */ public function getRelationById($id) { return $this->_neo4j->getClient()->getRelationship($id); }