Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MAVRICK-1 authored Feb 6, 2024
1 parent d2184c5 commit f73c534
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion iyp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,28 @@ def add_links(self, src_node, links):

self.tx.run(matches + where + merges).consume()
self.commit()


def add_relationship_properties(
self,
node_label_properties,
relationship,
connected_node_label_properties,
properties):
"""The function goes through each provided property and adds it to the
relationship between the specified nodes, but only if that property doesn't
already exist in the relationship."""
property_setters = ','.join([f'rel.{prop} = ${{props}}.${{prop}}' for prop in properties.keys()])
add_query = f"""
MATCH (node1:{node_label_properties})-[rel:{relationship}]-(node2:{connected_node_label_properties})
WITH rel
UNWIND keys($properties) AS prop
WHERE NOT EXISTS(rel[prop])
SET {property_setters}
"""
res = self.tx.run(add_query, properties=properties)
res.consume()
self.commit()

def batch_add_properties(self, id_prop_list):
"""Add properties to existing nodes.
Expand Down

0 comments on commit f73c534

Please sign in to comment.