Neo4j Visualization Library
    Preparing search index...

    Variable nvlResultTransformerConst

    nvlResultTransformer: ResultTransformer<
        {
            nodes: Node[];
            recordObjectMap: Map<
                string,
                | Node<Integer, Properties, string>
                | Relationship<Integer, Properties, string>
                | Path<Integer>,
            >;
            relationships: Relationship[];
        },
    > = ...

    Result transformer for the Neo4j JavaScript driver results to NVL graph elements.

    Collects every node, relationship and path (including nested lists) from all record fields and returns

    • nodes: { id: elementId } per node, no labels, properties or captions,
    • relationships: { id, from, to } per relationship using element ids,
    • recordObjectMap: Map<elementId, driver Node | Relationship> for looking up labels and properties.

    Nodes and relationships returned by several records appear several times in the arrays. NVL deduplicates by id when adding them, so this only matters if the arrays are processed before that. Driver Integer values are not converted; use toNumber() or toString() before putting them in captions.

    import * as neo4j from 'neo4j-driver'
    import { nvlResultTransformer, NVL } from '@neo4j-nvl/base'

    const run = async () => {
    const driver = neo4j.driver('{uri}', neo4j.auth.basic('{user}', '{password}'))
    const nvlGraph = await driver.executeQuery(
    'MATCH (a)-[r]-(b) RETURN a,r,b LIMIT 25',
    {},
    { resultTransformer: nvlResultTransformer }
    )

    const nvl = new NVL(document.getElementById('viz'), nvlGraph.nodes, nvlGraph.relationships)
    }