Anyone have any experience implementing relationships with time based properties?

I am wondering what the most effective way is to make relationships that can be queried in such a way:
match videos friend has watched less than 3 months ago for example.

I was looking through the neo4j documentation on temporal values but I am unsure about the scope of being able to apply useful queries after the fact of storing date relationship was created. My question is: does anyone have any experience using neo4j in a way where you query relationship parameters to find all LESS THAN a certain value (e.g all videos watched LESS THAN 2 days or 2 weeks or 2 years ago, whatever range)

Potential query
(a:Person)-[r:FRIENDS]-(b:Person)-[r2:WATCHED {date: x time ago in some time format maybe milliseconds since January 1 1970 probably}]-(c:Video) WHERE r2.date < y RETURN c

This could just be as simple as a SQL query problem which I will most likely find out in the next 2 or 24 hours. This query above may very well be the solution but just wanted to see if anyone else had a similar experience.

Check this:

1 Like

Ended up writing this method below to create watched relationships on view incrementation.
Will update this thread when I write recommendation query to filter: videos watched by friend less than x time ago

try {
    const d = new Date().getTime();
    let session = driver.session();
    let query = "match ( a:Person { name: $user }), ( b:Video { mpd: $mpd }) optional match (a)-[r:WATCHED]->(b) delete r merge (a)-[r2:WATCHED { time: $ms }]->(b) return a, r2, b";
    let params = { user: user, ms: d, mpd: mpd };
    return await session.run(query, params)
} catch (err) {
    return err;
}