MCPcopy Create free account
hub / github.com/Brickgraph/fast-graph / update_node

Function update_node

app/graph/crud.py:153–175  ·  view source on GitHub ↗
(node_id: int, attributes: dict)

Source from the content-addressed store, hash-verified

151# UPDATE properties of node in the graph
152@router.put('/update/{node_id}')
153async def update_node(node_id: int, attributes: dict):
154 # Check that property to update is not part of base list
155 for key in attributes:
156 if key in base_properties:
157 raise HTTPException(
158 status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
159 detail="Operation not permitted, that property field cannot be updated.",
160 headers={"WWW-Authenticate": "Bearer"})
161
162 cypher = '''MATCH (node) WHERE ID(node) = $id
163 SET node += $attributes
164 RETURN node, ID(node) as id, LABELS(node) as labels'''
165
166 with neo4j_driver.session() as session:
167 result = session.run(query=cypher,
168 parameters={'id': node_id, 'attributes': attributes})
169
170 node_data = result.data()[0]
171
172 # Return Node response
173 return Node(node_id=node_data['id'],
174 labels=node_data['labels'],
175 properties=node_data['node'])
176
177
178# DELETE node in the graph

Callers

nothing calls this directly

Calls 1

NodeClass · 0.90

Tested by

no test coverage detected