GithubHelp home page GithubHelp logo

docs-drivers's Issues

Update query from the documentation not working

I am trying to use neo4j driver in my typescript project and while trying query from documentation here, I encountered below mentioned syntax error.

Details
Neo4j version: neo4j:4.0 (Docker Compose)
Neo4j Driver npm version: 5.14.0

Sample code

import neo4j from "neo4j-driver";
import dotenv from "dotenv";
dotenv.config();

const driver = neo4j.driver(
  "bolt://localhost",
  neo4j.auth.basic(process.env.NEO4J_USER ?? "", process.env.NEO4J_PASS ?? "")
);

export async function getDriver() {
  const info = await driver.getServerInfo();
  console.log("Connected to Neo4j");
  console.log(info);
  return driver;
}

(async () => {
  const driver = await getDriver();
  const { summary } = await driver.executeQuery(
    `
  MATCH (p:Person WHERE p.name = $name)
  SET p.age = $age
  `,
    { name: "Alice", age: 42 }
  );
  console.log("Query counters:");
  console.log(summary.counters.updates());
})();

Error

> [email protected] dev /app/server
> ts-node app.ts

Connected to Neo4j
ServerInfo {
  address: 'localhost:7687',
  agent: 'Neo4j/4.0.12',
  protocolVersion: 3
}
/app/server/node_modules/.pnpm/[email protected]/node_modules/neo4j-driver-core/lib/result.js:613
    var error = new Error('');
                ^
Neo4jError: Invalid input 'W': expected whitespace, comment, NodeLabel, MapLiteral, a parameter, a parameter (old syntax), ')' or a relationship pattern (line 2, column 17 (offset: 19))
"  MATCH (p:Person WHERE p.name = $name)"
                   ^

    at captureStacktrace (/app/server/node_modules/.pnpm/[email protected]/node_modules/neo4j-driver-core/lib/result.js:613:17)
    at new Result (/app/server/node_modules/.pnpm/[email protected]/node_modules/neo4j-driver-core/lib/result.js:105:23)
    at newCompletedResult (/app/server/node_modules/.pnpm/[email protected]/node_modules/neo4j-driver-core/lib/transaction.js:520:12)
    at Object.run (/app/server/node_modules/.pnpm/[email protected]/node_modules/neo4j-driver-core/lib/transaction.js:352:20)
    at TransactionPromise.Transaction.run (/app/server/node_modules/.pnpm/[email protected]/node_modules/neo4j-driver-core/lib/transaction.js:183:34)
    at ManagedTransaction.run (/app/server/node_modules/.pnpm/[email protected]/node_modules/neo4j-driver-core/lib/transaction-managed.js:56:21)
    at QueryExecutor.<anonymous> (/app/server/node_modules/.pnpm/[email protected]/node_modules/neo4j-driver-core/lib/internal/query-executor.js:87:57)
    at step (/app/server/node_modules/.pnpm/[email protected]/node_modules/neo4j-driver-core/lib/internal/query-executor.js:51:23)
    at Object.next (/app/server/node_modules/.pnpm/[email protected]/node_modules/neo4j-driver-core/lib/internal/query-executor.js:32:53)
    at /app/server/node_modules/.pnpm/[email protected]/node_modules/neo4j-driver-core/lib/internal/query-executor.js:26:71 {
  constructor: [Function: Neo4jError] { isRetriable: [Function (anonymous)] },
  code: 'Neo.ClientError.Statement.SyntaxError',
  retriable: false
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.