RedisGraph / redisgraph-py

RedisGraph python client
https://redisgraph.io
BSD 3-Clause "New" or "Revised" License
189 stars 49 forks source link

Using Nodes to update existing records #81

Open boris-42 opened 4 years ago

boris-42 commented 4 years ago

Currently, this framework supports only creation of new nodes, but if we want to update some properties, manual requests are required.

As far as I understand, there are 2 approaches here, one through MERGE (to ensure that record exists and update) or MATCH (to update record only if it exists) and it's recommend to use external ids.

The proposal is to add to methods to graph: def update(node: Node) -> MATCH+ SET and

def ensure(node: Node) -> MERGE + SET

To do match or merge we need to have ID, which in real life is usually is some UUID from some external system. To solve this we can extend Node.__init__ to allow to pass "id_key" or "id" which will be the name of the property that is use as external id

Is community interested in this kind of change?