JsNode¶
Represents a graph node returned from queries or createNode().
Properties¶
| Property | Type | Description |
|---|---|---|
id | number | Internal node ID |
labels | string[] | Node labels |
Methods¶
get()¶
Get a property value by key. Returns undefined if the property doesn't exist.
const node = db.getNode(0);
console.log(node.get('name')); // 'Alix'
console.log(node.get('missing')); // undefined
properties()¶
Get all properties as a plain object.
hasLabel()¶
Check if the node has a specific label.
toString()¶
String representation of the node.
Example¶
// From query results
const result = await db.execute('MATCH (p:Person) RETURN p');
for (const node of result.nodes()) {
console.log(`${node.id}: ${node.labels.join(':')} - ${node.get('name')}`);
}
// Direct creation
const node = db.createNode(['Person', 'Employee'], { name: 'Alix', age: 30 });
console.log(node.id);
console.log(node.labels);
console.log(node.properties());
// Label management
db.addNodeLabel(node.id, 'Manager');
db.removeNodeLabel(node.id, 'Employee');
console.log(db.getNodeLabels(node.id)); // ['Person', 'Manager']