Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-12-2021 06:56 PM
Hello,
I made a project database in Neo4j Desktop and ran some queries in Neo4j Browser. Now I'm trying to add a couple nodes via Node.js running a JavaScript file, but it's not working. Here's the code in the JavaScript file:
const neo4j = require('neo4j-driver');
const driver = neo4j.driver(
'neo4j://localhost:7687',
neo4j.auth.basic('neo4j', 'neo4j')
);
const session = driver.session()
session.run('CREATE (n1:flashcard {English: "Hello"}), (n2:flashcard {English: "Goodbye"})');
session.close();
driver.close();
I'm not sure that I have the right URI in neo4j.driver()
. Where am I supposed to get it? I ran :sysinfo
in the browser and it listed the database name as neo4j and the address as localhost:7687, which is what I put.
05-13-2021 04:19 AM
Your code looks basically OK, but it's hard to figure out what's going wrong without the error message.
Paste the full output of your program.
05-13-2021 09:32 AM
There is no output. It just runs the program, and then I check the database in the browser, and see that two nodes haven't been added. What should I do?
By the way, it looks like the :server status
command in the browser gives me the right URI.
05-13-2021 11:38 AM
How do you check the existing nodes in your Neo4j?
05-13-2021 12:32 PM
With MATCH (n) RETURN n
in the Neo4j browser.
05-13-2021 01:57 PM
There must be something missing in the provided information, for now everything looks good.
01-14-2022 07:56 AM
How to specify the local DBMS. Databases (system and neo4j) are created under DBMS on local desktop.
08-21-2022 03:13 PM - edited 08-21-2022 03:16 PM
Credit goes to Mr: Gary Mann of Neo4j
>> code from Gary >> ie: session object creation line can spicify the database , ie: session = driver.session({database:'
const neo4j = require('neo4j-driver')
const uri= "neo4j://localhost:7687"
const user="neo4j"
const password="password"
const driver = neo4j.driver(uri, neo4j.auth.basic(user, password))
async function query() {
try {
session = driver.session({database:'
const result = await session.run( 'MATCH (n) RETURN count(n) AS cnt', {});
const res = result.records[0].get(0)
console.log("Result:", res);
return res;
} catch (e) {
console.log(e);
} finally {
console.log("closing ...");
await session.close();
await driver.close();
}
}
query();
05-20-2022 03:39 PM
hi
did you manage to connect to neo4j desktop? do you have a solution?
All the sessions of the conference are now available online