Creating a Driver Instance

Your challenge is to add a new Driver instance to an existing file with the connection details provided. Once you have created the Driver, you must open a new session and run a Cypher statement to find the director of Toy Story.

Open Challenge in an Online IDE →

Steps

  1. Install the Neo4j JavaScript Driver in the integrated terminal window

  2. Use the neo4j object to create a new instance of the Driver with the credentials provided:

    • NEO4J_URI is the connection string

    • NEO4J_USERNAME and NEO4J_PASSWORD should be used to create the authentication token.

  3. Once you have created the Driver, open a new session and run the following query:

    cypher
    Find the Director
    Unresolved directive in lesson.adoc - include::https://raw.githubusercontent.com/neo4j-graphacademy/llm-vectors-unstructured/main/cypher/movie-director.cypher[]

    The statement requires the following parameters:

    typescript
    { title: 'Toy Story' }
  4. To find the answer, click the Debug icon to the left of the window and run Create Driver Challenge task, or use the integrated terminal window to run the following command:

    sh
    Run The Challenge
    ts-node src/challenges/create-driver/challenge.ts
  5. Once you have the result, copy and paste it into the text box below and click Check Answer.

View the Solution
ts
Unresolved directive in lesson.adoc - include::https://raw.githubusercontent.com/neo4j-graphacademy/llm-vectors-unstructured/main/src/challenges/create-driver/solution.ts[]

Your Answer

Who directed Toy Story?

Take the Director value output from the statement above and paste it into the box below.

  • ✓ John Lasseter

Hint

You need to call the neo4j.driver() object to create a Driver instance using the NEO4J_URI, NEO4J_USERNAME and NEO4J_PASSWORD variables, then open a new session, execute the Cypher statement and log the Director value of the first record.

Your console.log() statement should look similar to the code block below:

ts
console.log(res.records[0].get('Director'))

Copy the answer without any quotes or whitespace.

Solution

John Lasseter directed Toy Story.

Compare your code with the solution here

ts
Unresolved directive in questions/1-director.adoc - include::https://raw.githubusercontent.com/neo4j-graphacademy/llm-vectors-unstructured/main/src/challenges/create-driver/solution.ts[]

Click here to view the solution.

Lesson Summary

In this challenge, you used your knowledge to create a driver instance and run a Cypher statement.

In the next lesson, you will learn about the different transaction functions and when to use them.

Chatbot

Hi, I am an Educational Learning Assistant for Intelligent Network Exploration. You can call me E.L.A.I.N.E.

How can I help you today?