Example #1
0
 /**
  * Add clause to match the relationship we want to delete
  *
  * @param IdentityInterface $identity
  * @param $object $entity
  * @param Query  $query
  *
  * @return Query
  */
 private function matchRelationship(IdentityInterface $identity, $entity, Query $query) : Query
 {
     $meta = $this->metadatas->get(get_class($entity));
     $name = $this->name->sprintf(md5($identity->value()));
     $this->variables = $this->variables->add((string) $name);
     return $query->match()->linkedTo()->through((string) $meta->type(), (string) $name)->withProperty($meta->identity()->property(), (string) $name->prepend('{')->append('_identity}'))->withParameter((string) $name->append('_identity'), $identity->value());
 }
Example #2
0
 /**
  * Add the clause to match the target node in case it's node that is not
  * persisted via the current query
  *
  * @param Str $name
  * @param RelationshipEdge $meta
  * @param mixed $value
  * @param Query $query
  *
  * @return Query
  */
 private function matchEdge(Str $name, RelationshipEdge $meta, $value, Query $query) : Query
 {
     if ($this->variables->contains((string) $name)) {
         return $query;
     }
     $this->variables = $this->variables->add((string) $name);
     return $query->match((string) $name)->withProperty($meta->target(), (string) $name->prepend('{')->append('_props}.')->append($meta->target()))->withParameter((string) $name->append('_props'), [$meta->target() => $value]);
 }
Example #3
0
 /**
  * Add the match clause for a relationship
  *
  * @param IdentityInterface $identity
  * @param object $entity
  * @param Relationship $meta
  * @param CollectionInterface $changeset
  * @param Query $query
  *
  * @return Query
  */
 private function matchRelationship(IdentityInterface $identity, $entity, Relationship $meta, CollectionInterface $changeset, Query $query) : Query
 {
     $name = $this->name->sprintf(md5($identity->value()));
     $this->variables = $this->variables->put($name, $this->buildProperties($changeset, $meta->properties()));
     return $query->match()->linkedTo()->through((string) $meta->type(), (string) $name)->withProperty($meta->identity()->property(), (string) $name->prepend('{')->append('_identity}'))->withParameter((string) $name->append('_identity'), $identity->value());
 }