I have a Linked-List of LogEntries
. Each entry has a date. Every user has exactly 1 Log.
What's the best way to splice in a new log entry if I receive a date in the past?
(log:Log)
(e1:LogEntry {date: Date('2020-03-19')})
(e2:LogEntry {date: Date('2020-03-17')})
…
CREATE (log)-[:PREV_ENTRY]->(e1)
CREATE (e1)-[:PREV_ENTRY]->(e2)
CREATE (e2)-[:PREV_ENTRY]->(e3)
CREATE (e3)-[:PREV_ENTRY]->(e4)
I'm building a public graphql API to trace contact of COVID-19 case: https://github.com/mmmoli/contacttracing.app-graphql-api/blob/master/src/appConfigs/schema.ts#L55
Any help would be awesome!
Inspiration from Max's Fraud post: https://maxdemarzi.com/2019/08/19/finding-fraud/
Is this when you're first creating the database (i.e. the entries weren't sorted to start) or is this entry appearing later on and you're trying to update/insert with a new entry? If I'm understanding correctly, you want to insert a node in the chain for the log. How about
EDIT: Included additional constraint to make sure matching the chain finds one set of nodes between which to insert the new entry
That should work, but for completeness, here's the script I used to create the sample chain