LoginSignup
1
0

More than 3 years have passed since last update.

node.jsでneo4jを使ってみる

Posted at

neo4jドライバーのインストール

#npm install neo4j-driver

neo4jサーバーへの接続

const neo4j = require('neo4j-driver')

const driver = neo4j.driver("bolt://サーバーアドレス:7687", neo4j.auth.basic("ユーザー名", "パスワード"))
const session = driver.session()
const personName = 'Alice'

try {
  const result = await session.run(
    'CREATE (a:Person {name: $name}) RETURN a',
    { name: personName }
  )

  const singleRecord = result.records[0]
  const node = singleRecord.get(0)

  console.log(node.properties.name)
} finally {
  await session.close()
}

// on application exit:
await driver.close()

参考:https://neo4j.com/developer/javascript/
APIマニュアル:https://neo4j.com/docs/api/javascript-driver/4.1/

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0