Learn with Jason as a Graph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a graph of episodes and guests | |
CALL apoc.load.json('https://www.learnwithjason.dev/api/episodes') | |
YIELD value | |
// | |
MERGE (e:Episode { | |
id: value._id | |
}) | |
ON CREATE SET | |
e.createdAt = datetime(), | |
e += value { .title, .description, .demo, .repo, .links, .youtubeID, slug: value.slug.current } | |
// Only ever one host... | |
// MERGE (host:Person {name: value.host.name}) | |
// MERGE (host)-[:HOSTED]->(e) | |
// Create guest node and relationship to the | |
FOREACH (guest in value.guest | | |
MERGE (g:Person {name: guest.name}) | |
ON CREATE SET g.twitter = guest.twitter | |
MERGE (e)-[:HAS_GUEST]->(g) | |
) | |
// Added 93 labels, created 93 nodes, set 477 properties, created 48 relationships, completed after 1957 ms. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get most popular tags | |
MATCH (t:Tag) | |
RETURN t.name, size((t)<-[:HAS_TAG]-()) AS episodes | |
ORDER BY episodes DESC | |
LIMIT 10; | |
// Episodes with tag | |
MATCH (t:Tag {name: "nextjs"})<-[:HAS_TAG]-(e)-[:HAS_GUEST]->(g) | |
RETURN e.title, g.name AS guest, g.twitter AS twitter; | |
// Similar Episodes | |
MATCH (e1:Episode)-[:HAS_TAG]->(t)<-[:HAS_TAG]-(e2) | |
RETURN e1.title, e2.title, count(*) AS inCommon, collect(t.name) AS tags | |
ORDER BY inCommon DESC | |
LIMIT 10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment