@@ -175,23 +175,18 @@ def update_relationship_examples(j1, relationship_id, from_entity_id, to_entity_
175175 )
176176 print (f"Updated with custom timestamp\n " )
177177
178- def delete_relationship_examples (j1 , relationship_id ):
178+ def delete_relationship_examples (j1 , relationship_id , from_entity_id , to_entity_id ):
179179 """Demonstrate relationship deletion."""
180180
181181 print ("=== Relationship Deletion Examples ===\n " )
182182
183- # 1. Basic deletion
184183 print ("1. Deleting a relationship:" )
185- delete_result = j1 .delete_relationship (relationship_id = relationship_id )
186- print (f"Deleted relationship: { delete_result ['relationship' ]['_id' ]} \n " )
187-
188- # 2. Deletion with timestamp
189- print ("2. Deleting with specific timestamp:" )
190- j1 .delete_relationship (
184+ delete_result = j1 .delete_relationship (
191185 relationship_id = relationship_id ,
192- timestamp = int (time .time ()) * 1000
186+ from_entity_id = from_entity_id ,
187+ to_entity_id = to_entity_id
193188 )
194- print (f"Deleted with timestamp \n " )
189+ print (f"Deleted relationship: { delete_result [ 'relationship' ][ '_id' ] } \n " )
195190
196191def relationship_lifecycle_example (j1 , from_entity_id , to_entity_id ):
197192 """Demonstrate complete relationship lifecycle."""
@@ -234,7 +229,11 @@ def relationship_lifecycle_example(j1, from_entity_id, to_entity_id):
234229
235230 # 4. Delete relationship
236231 print ("4. Deleting relationship:" )
237- j1 .delete_relationship (relationship_id = relationship_id )
232+ j1 .delete_relationship (
233+ relationship_id = relationship_id ,
234+ from_entity_id = from_entity_id ,
235+ to_entity_id = to_entity_id
236+ )
238237 print ("Deleted successfully" )
239238
240239 # 5. Verify deletion
@@ -281,14 +280,22 @@ def network_relationship_example(j1):
281280 'bandwidth' : '100Mbps'
282281 }
283282 )
284- relationships .append (relationship ['relationship' ]['_id' ])
283+ relationships .append ({
284+ 'id' : relationship ['relationship' ]['_id' ],
285+ 'from' : entities [i ],
286+ 'to' : entities [i + 1 ]
287+ })
285288 print (f"Created connection { i } : { relationship ['relationship' ]['_id' ]} " )
286289
287290 print (f"Created { len (entities )} nodes with { len (relationships )} connections" )
288291
289292 # Clean up
290- for relationship_id in relationships :
291- j1 .delete_relationship (relationship_id = relationship_id )
293+ for rel in relationships :
294+ j1 .delete_relationship (
295+ relationship_id = rel ['id' ],
296+ from_entity_id = rel ['from' ],
297+ to_entity_id = rel ['to' ]
298+ )
292299 for entity_id in entities :
293300 j1 .delete_entity (entity_id = entity_id )
294301
@@ -356,7 +363,11 @@ def access_control_relationship_example(j1):
356363 print ("Updated access level to write" )
357364
358365 # Clean up
359- j1 .delete_relationship (relationship_id = access_relationship ['relationship' ]['_id' ])
366+ j1 .delete_relationship (
367+ relationship_id = access_relationship ['relationship' ]['_id' ],
368+ from_entity_id = user_entity ['entity' ]['_id' ],
369+ to_entity_id = resource_entity ['entity' ]['_id' ]
370+ )
360371 j1 .delete_entity (entity_id = user_entity ['entity' ]['_id' ])
361372 j1 .delete_entity (entity_id = resource_entity ['entity' ]['_id' ])
362373
@@ -397,7 +408,11 @@ def main():
397408 relationships_to_clean = [basic_rel , props_rel , complex_rel ]
398409 for rel in relationships_to_clean :
399410 try :
400- j1 .delete_relationship (relationship_id = rel ['relationship' ]['_id' ])
411+ j1 .delete_relationship (
412+ relationship_id = rel ['relationship' ]['_id' ],
413+ from_entity_id = from_entity_id ,
414+ to_entity_id = to_entity_id
415+ )
401416 print (f"Cleaned up relationship: { rel ['relationship' ]['_id' ]} " )
402417 except Exception :
403418 # Relationship may already be deleted or not exist
0 commit comments