I have a graph that contains a relationship between users, showing what user has visited another\'s profile, and when:
(visitor:User)-[:VISITED]->(visitee:Use
The simplest would be to use an ORDER BY
and a LIMIT
before the DELETE
. I.e.:
MATCH (visitor:User)-[r:VISITED]->(User)
WHERE visitor.user_id = %s
WITH r ORDER BY r.date LIMIT 1
DELETE r
A more efficient mechanism may be to keep a linked list of visit (there's some discussion on this here: http://docs.neo4j.org/chunked/stable/cypherdoc-linked-lists.html)