From 49777f1776d688893a0b00790610bb89826e0576 Mon Sep 17 00:00:00 2001 From: Vinoth Ramiah Date: Fri, 16 Jul 2021 21:07:04 +0100 Subject: [PATCH] CreateAsset should overwrite fields on an existing match --- database/neo_client.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/database/neo_client.go b/database/neo_client.go index 2dd32ee..41e4794 100644 --- a/database/neo_client.go +++ b/database/neo_client.go @@ -399,10 +399,13 @@ func (neo *Neo4j) CreateAsset(id string, assetid string, assettype string, remot } defer conn.Close() + fields := "memory.key = {key}, asset.type = {type}, asset.remotepath = {remotepath}, asset.remotepathorig = {remotepathorig}, asset.createdate = {createdate}, asset.location = {location}, asset.duration = {duration}, asset.originaluti = {originaluti}, asset.pixelwidth = {pixelwidth}, asset.pixelheight = {pixelheight}, asset.md5 = {md5}, asset.totalsize = {totalsize} " + stmt, err := conn.PrepareNeo( "MATCH (user:User { id: {id} }) " + "MERGE (user) <- [memory:MEMORY] - (asset:Asset { uuid: {assetid} }) " + - "ON CREATE SET memory.key = {key}, asset.type = {type}, asset.remotepath = {remotepath}, asset.remotepathorig = {remotepathorig}, asset.createdate = {createdate}, asset.location = {location}, asset.duration = {duration}, asset.originaluti = {originaluti}, asset.pixelwidth = {pixelwidth}, asset.pixelheight = {pixelheight}, asset.md5 = {md5}, asset.totalsize = {totalsize} ") + "ON CREATE SET " + fields + + "ON MATCH SET " + fields) if err != nil { return err }