Building Neo4j Applications with Python - My Favorites List

This is more of a question related to the design of the database.

Consider this function as provided in the course:

Define a new transaction function to create a HAS_FAVORITE relationship

def add_to_favorites(tx, user_id, movie_id):
row = tx.run("""
MATCH (u:User {userId: $userId})
MATCH (m:Movie {tmdbId: $movieId})
MERGE (u)-[r:HAS_FAVORITE]->(m)
ON CREATE SET u.createdAt = datetime()
RETURN m {
.*,
favorite: true
} AS movie
""", userId=user_id, movieId=movie_id).single()

Why are we adding the createdAt=datetime property to the user node? What is the logic behind it?

I am thinking that you would add the createdAt property to the newly created HAS_FAVORITE relationship to keep track of when a user favorited a movie. Interested to know the reasoning here. Thanks.

That's a good point, it looks like a typo. Instead, it should be SET r.createdAt = datetime()

Thanks for spotting this, I'll get the course updated