diff --git a/apps/graph-store/src/message/message.service.ts b/apps/graph-store/src/message/message.service.ts index 54a7ec3..64e321d 100644 --- a/apps/graph-store/src/message/message.service.ts +++ b/apps/graph-store/src/message/message.service.ts @@ -16,14 +16,14 @@ RETURN message const UPDATE_MESSAGE = ` MATCH (user:TGUser { id: $user.id }) MATCH (chat:TGChat { id: $chat.id }) -MATCH (latest:TGMessage { id: $message.message_id })-[:SENT_IN]->(chat) -WHERE NOT EXISTS (()-[:EDITED]->(latest)) +MATCH (previous:TGMessage { id: $message.message_id })-[:SENT_IN]->(chat) +WHERE NOT EXISTS ((previous)-[:EDITED]->()) MERGE (user)-[:CREATED_MESSAGE]->(message:TGMessage { id: $message.message_id, edit_date: $message.edit_date })-[:SENT_IN]->(chat) ON CREATE SET message = apoc.map.merge(message, apoc.map.clean($message, ['id'], [null])), message.created_at = timestamp(), message.updated_at = timestamp() -MERGE (message)-[:EDITED]->(latest) +MERGE (previous)-[:EDITED]->(message) RETURN message `;