@@ -141,3 +141,64 @@ async def find(
141141 )
142142
143143 return response .data
144+
145+ def create_many (
146+ self ,
147+ * ,
148+ source : dict ,
149+ target : dict ,
150+ type : Optional [str ] = None ,
151+ direction : Optional [str ] = None ,
152+ many_to_many : Optional [bool ] = None ,
153+ transaction : Optional [Union [Transaction , str ]] = None ,
154+ ) -> dict :
155+ """Bulk create relationships by matching keys or many-to-many cartesian.
156+
157+ Modes:
158+ 1. Key-match (default): requires source.key and target.key, creates relationships where source[key] = target[key].
159+ 2. many_to_many=True: cartesian across filtered sets (requires where filters on both source & target and omits keys).
160+
161+ Args:
162+ source (dict): { label: str, key?: str, where?: dict }
163+ target (dict): { label: str, key?: str, where?: dict }
164+ type (str, optional): Relationship type override.
165+ direction (str, optional): 'in' | 'out'. Defaults to 'out' server-side when omitted.
166+ many_to_many (bool, optional): Enable cartesian mode (requires filters, disallows keys).
167+ transaction (Transaction|str, optional): Transaction context.
168+
169+ Returns:
170+ dict: API response payload.
171+ """
172+ headers = Transaction ._build_transaction_header (transaction )
173+ payload : dict = {"source" : source , "target" : target }
174+ if type :
175+ payload ["type" ] = type
176+ if direction :
177+ payload ["direction" ] = direction
178+ if many_to_many is not None :
179+ payload ["manyToMany" ] = many_to_many
180+ return self .client ._make_request ("POST" , "/relationships/create-many" , payload , headers )
181+
182+ def delete_many (
183+ self ,
184+ * ,
185+ source : dict ,
186+ target : dict ,
187+ type : Optional [str ] = None ,
188+ direction : Optional [str ] = None ,
189+ many_to_many : Optional [bool ] = None ,
190+ transaction : Optional [Union [Transaction , str ]] = None ,
191+ ) -> dict :
192+ """Bulk delete relationships using same contract as create_many.
193+
194+ See create_many for argument semantics.
195+ """
196+ headers = Transaction ._build_transaction_header (transaction )
197+ payload : dict = {"source" : source , "target" : target }
198+ if type :
199+ payload ["type" ] = type
200+ if direction :
201+ payload ["direction" ] = direction
202+ if many_to_many is not None :
203+ payload ["manyToMany" ] = many_to_many
204+ return self .client ._make_request ("POST" , "/relationships/delete-many" , payload , headers )
0 commit comments